Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: add a phrase about parentheses.

Table of Contents

Pure Negative Queries

One common situation encountered in search with Lucene-based programs is the problem of pure negative query clauses. This is a query clause that consists ONLY of negative phrases, using the - notation or the "NOT" boolean operator.

...

This is because when the entire query is a single negative clause without any complexity such as parentheses, Solr is able to detect the impossible situation and fix it for you. A query of -field:value is translated internally into *:* -field:value by Solr before it gets sent down to the Lucene layer – a starting point of all documents is implicitly added to the query, and then the subtraction works.

...