public interface

LuceneQueryModifier

com.atlassian.jira.issue.search.util.LuceneQueryModifier
Known Indirect Subclasses

Class Overview

This class will clone the org.apache.lucene.search.Query and add a org.apache.lucene.search.MatchAllDocsQuery to the portion of the query that require them. This inspects the query to determine if there are any nodes in the query that are marked as MUST_NOT AND they do not have a positive query to work against. This is because Lucene will drop queries of this kind instead of trying to find the correct result. When we specify a query that is -A || B lucene treats this as equivilent to B. When we specify this query what we mean is (-A && ALL_VALUES) || B which is obviously not equivilent to B. The algorithm for determining if a org.apache.lucene.search.BooleanQuery should have a org.apache.lucene.search.MatchAllDocsQuery added to it with an occur of MUST_NOT is: Case 1: BooleanQuery contains only MUST_NOT clauses THEN add a org.apache.lucene.search.MatchAllDocsQuery Case 2: BooleanQuery contains at least one MUST and no SHOULD THEN do not add a org.apache.lucene.search.MatchAllDocsQuery Case 3: BooleanQuery contains at least one SHOULD THEN add a org.apache.lucene.search.MatchAllDocsQuery to each MUST_NOT portion of the query. This may mean that we need to rewrite the a single term to be a BooleanQuery that contains the single term AND the org.apache.lucene.search.MatchAllDocsQuery. NOTE: A BooleanQuery that contains at least one MUST and at least one SHOULD is the same as Case 2 since the MUST portion of the query will provide a positive set of results.

Summary

Public Methods
Query getModifiedQuery(Query originalQuery)
Will clone and rewrite the query as per the rules defined above.

Public Methods

public Query getModifiedQuery (Query originalQuery)

Will clone and rewrite the query as per the rules defined above.

Parameters
originalQuery defines the lucene query to inspect, must not be null.
Returns
  • the modified query that will return the right results when run.