public interface LuceneQueryModifier
Queryand add a
MatchAllDocsQueryto 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
BooleanClause.Occur.MUST_NOTAND 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
BooleanQueryshould have a
MatchAllDocsQueryadded to it with an occur of
BooleanClause.Occur.MUST_NOTis: Case 1: BooleanQuery contains only
BooleanClause.Occur.MUST_NOTclauses THEN add a
MatchAllDocsQueryCase 2: BooleanQuery contains at least one
BooleanClause.Occur.SHOULDTHEN do not add a
MatchAllDocsQueryCase 3: BooleanQuery contains at least one
BooleanClause.Occur.SHOULDTHEN add a
BooleanClause.Occur.MUST_NOTportion 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
MatchAllDocsQuery. NOTE: A BooleanQuery that contains at least one
BooleanClause.Occur.MUSTand at least one
BooleanClause.Occur.SHOULDis the same as Case 2 since the MUST portion of the query will provide a positive set of results.
org.apache.lucene.search.Query getModifiedQuery(org.apache.lucene.search.Query originalQuery)
originalQuery- defines the lucene query to inspect, must not be null.
Copyright © 2002-2015 Atlassian. All Rights Reserved.