1

I have the following fields indexed in Solr:

  • FIELD_1
  • FIELD_2
  • FIELD_3

I would like to search for a document where FIELD_3=X but if FIELD_3 is empty (or non existent in the document), to search in FIELD_2, and then in FIELD_1

Is this kind of query possible in Solr ?

Thank you

Simo L.
  • 321
  • 1
  • 3
  • 20

1 Answers1

1

Assuming that you only want to search against FIELD2 and FIELD1 if the previous fields are empty (and not if they have a value, but it didn't generate a hit), something like:

q=FIELD3:foo OR (FIELD2:foo AND NOT FIELD3:[* TO *]) OR (FIELD1:foo AND NOT FIELD2:[* TO *] AND NOT FIELD3:[* TO *])

should work.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84