This is one of the idiosyncrasies of the NOT boolean operator. I prefer using the "-" operator for boolean NOT <https://solr.apache.org/guide/solr/latest/query-guide/standard-query-parser.html#the-boolean-operator-2>. The way to see it is that it behaves like a set operation where you give Solr a result set and then subtract what you DON'T want. The below query should work for you:
http://host:8983/solr/solr1/select?q=(*:* -( <http://host:8983/solr/solr1/select?q=(NOT(> attribute1:there)) AND (attribute2:Document) So you are basically telling Solr to consider results from the MatchAllDocsQuery (*:*) and subtracting the results for (attribute1:there) -Rahul On Wed, Jan 22, 2025 at 10:51 AM Farmerie, Henry <henry.farme...@siemens.com.invalid> wrote: > Hello, > I'm using Solr 9.7.0, and I observe the following query returns zero > results: > > http://host:8983/solr/solr1/select?q=(NOT( attribute1:there)) AND > (attribute2:Document)< > http://host:8983/solr/solr1/select?q=(NOT(%20attribute1:there))%20AND%20(attribute2:Document) > > > > However, if I do the search criteria on each side of the "AND" separately, > I get results back, and they match: > > http://host:8983/solr/solr1/select?q=(NOT( attribute1:there)) > http://host:8983/solr/solr1/select?q=(attribute2:Document) > > Conversely, if I have a query that omits the NOT operator for the criteria > on the left side of the AND operator, it works as expected and returns > results: > > http://host:8983/solr/solr1/select?q=( attribute1:truevalue) AND > (attribute2:Document)< > http://host:8983/solr/solr1/select?q=(%20attribute1:truevalue)%20AND%20(attribute2:Document) > > > > So it appears that using the NOT operator as part of the criteria used > when AND'ed with another criteria, "breaks" the query. > > Has anyone else seen this behavior, and if so, is there a way to make it > work? > > -Henry Farmerie > > >