Yes, would be easier and performances wise if you do this at index time. In the other hand, if you can't, had you tried nested query parser?
https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-NestedQueryParser Ciao, Vincenzo -- mobile: 3498513251 skype: free.dev > On 13 Sep 2017, at 17:20, Walter Underwood <wun...@wunderwood.org> wrote: > > How about doing that logic at index time? Make a new field, then copy into it > with that logic using an update request processor. > > wunder > Walter Underwood > wun...@wunderwood.org > http://observer.wunderwood.org/ (my blog) > > >> On Sep 12, 2017, at 2:05 PM, Peter Kirk <p...@alpha-solutions.dk> wrote: >> >> Hi >> >> I want to formulate an fq which filters on fields depending on what fields >> exist in each document. >> >> For example: >> if the document has a "field1" then use "field1:[1 TO 100]"; >> but if there is no "field1", then check if there is a "field2"; >> if there is a "field2" then use "field2:[1 TO 100]; >> but if there is no "field2", then use "field3:[1 TO 100]. >> >> Something like: >> ?q=*:*&fq=if(exists(field1),field1:[1 TO 100],if(exists(field2),field2:[1 TO >> 100], field3:[1 TO 100])) >> >> >> But is this does not work. >> Is it even possible? >> >> Thanks, >> Peter >