On Solr 6.5.1, I have a *_txt_en
field and a string
document-type field. On these fields, I would like to build a query of the form:
Match all documents of a certain document-type, where:
- Certain phrases ("phrase one", "phrase two") must occur in the text field to be matched
- But if other phrases ("phrase three", "phrase four", "phrase five") also occur in this field, do not match it.
My current Solr query that I wrote looks as follows:
(documenttype:references AND (field:"phrase one" OR field:"phrase two")) AND NOT field:"phrase three" AND NOT field:"phrase four" AND NOT field:"phrase five"
An alternative I can think of is:
(documenttype:references AND (field:"phrase one" OR field:"phrase two")) AND NOT (field:"phrase three" OR field:"phrase four" OR field:"phrase five")
The above queries seems to work on a toy data set of a couple of examples. But I learned that with Solr, there are some unwritten rules and not obvious pitfalls, especially with negations as part of Boolean queries.
For a query as I described, is this the right syntax to form them ?