Charles: Yeah, the fact that Solr/Lucene doesn't implement strict boolean logic is something I certainly fumbled with..
Here's an excellent writeup of what it _does_ do: https://lucidworks.com/blog/why-not-and-or-and-not/ Best, Erick On Wed, Dec 31, 2014 at 10:12 AM, Charles Sanders <csand...@redhat.com> wrote: > Shawn, > Thanks. Not what I expected (still thinking in database terms), but makes > sense based on the results. I understand now and I think I have the filter I > need. > > Charles > > > ----- Original Message ----- > > From: "Shawn Heisey" <apa...@elyograg.org> > To: solr-user@lucene.apache.org > Sent: Wednesday, December 31, 2014 12:56:02 PM > Subject: Re: Filter Queries Do Not Allow OR operator ?? > > On 12/31/2014 10:45 AM, Charles Sanders wrote: >> I'm running solr 4.8. On my test system I ran the query >> http://localhost:8888/solr/collection1/select?q=*:*&fq=-hasPublishedRevision:true&rows=100&fl=documentKind, >> hasPublishedRevision&wt=json&indent=true >> >> The results are as expected. It returns 59 documents of various >> documentKinds, all having a hasPublishedRevision value of false or none at >> all (just not true). >> >> Now I run the query >> http://localhost:8888/solr/collection1/select?q=*:*&fq=-hasPublishedRevision:true >> OR documentKind:Solution&rows=100&fl=documentKind, >> hasPublishedRevision&wt=json&indent=true >> >> This does not return the expected results. This returns only 5 documents. >> All have documentKind as Solution. The results returned are consistent with >> an AND condition in the filter query not an OR. >> >> I expected the filter query used to have returned all documents that do not >> have a hasPublishedRevision value of true (regardless of documentKind), as >> well as all documents with a documentKind of Solution (regardless to >> hasPublishedRevision value). >> >> Obviously filter queries do not support 'any' boolean logic. I will have to >> find a work around for this issue. > > Your filter query starts with a negative clause. A simple truism for > Solr: You cannot subtract from nothing. If the negative query is > simple enough, Solr can detect it and implicitly add the *:* (all > documents) for the negative clause to subtract from, but as soon as > there is any complexity at all, Solr is not able to recognize the > situation and repair it automatically. > > Try one of these filters instead. I am not sure exactly what you're > after, so you will have to pick the one that does what you need: > > fq=*:* -(hasPublishRevision:true OR documentKind:Solution) > fq=(*:* -hasPublishRevision:true) OR documentKind:Solution > > Thanks, > Shawn > >