SOLR NOT condition trick

Apache SOLR, an “open source enterprise search server”, demonstrates indecently inconsistent and illogical handling of NOT conditions in it’s queries (like “x:1 AND NOT x:2” producing 0 results, yet “x:1 AND (NOT x:2)” producing correct results etc).

We couldn’t play with braces because our conditions are autogenerated, so we needed a generic solution for this.

Fortunately, workaround has been found for this with simple Googling. Instead of querying for “… AND/OR (NOT [condition])” just use “… AND/OR (*:* NOT [condition])” or “… AND/OR (*:* AND NOT [condition])“.

Advertisements