Package org.apache.lucene.queries
Class BlendedTermQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.queries.BlendedTermQuery
public abstract class BlendedTermQuery
extends org.apache.lucene.search.Query
BlendedTermQuery can be used to unify term statistics across
one or more fields in the index. A common problem with structured
documents is that a term that is significant in on field might not be
significant in other fields like in a scenario where documents represent
users with a "first_name" and a "second_name". When someone searches
for "simon" it will very likely get "paul simon" first since "simon" is a
an uncommon last name ie. has a low document frequency. This query
tries to "lie" about the global statistics like document frequency as well
total term frequency to rank based on the estimated statistics.
While aggregating the total term frequency is trivial since it
can be summed up not every Similarity
makes use of this statistic. The document frequency which is used in the
ClassicSimilarity
can only be estimated as an lower-bound since it is a document based statistic. For
the document frequency the maximum frequency across all fields per term is used
which is the minimum number of documents the terms occurs in.
-
Constructor Summary
Constructors Constructor Description BlendedTermQuery(org.apache.lucene.index.Term[] terms, float[] boosts)
-
Method Summary
Modifier and Type Method Description protected void
blend(org.apache.lucene.index.TermStates[] contexts, int maxDoc, org.apache.lucene.index.IndexReader reader)
static BlendedTermQuery
commonTermsBlendedQuery(org.apache.lucene.index.Term[] terms, float[] boosts, float maxTermFrequency)
Deprecated.Since max_score optimization landed in 7.0, normal MultiMatchQuery will achieve the same result without any configuration.static BlendedTermQuery
dismaxBlendedQuery(org.apache.lucene.index.Term[] terms, float tieBreakerMultiplier)
static BlendedTermQuery
dismaxBlendedQuery(org.apache.lucene.index.Term[] terms, float[] boosts, float tieBreakerMultiplier)
boolean
equals(java.lang.Object o)
java.util.List<org.apache.lucene.index.Term>
getTerms()
int
hashCode()
org.apache.lucene.search.Query
rewrite(org.apache.lucene.index.IndexReader reader)
protected abstract org.apache.lucene.search.Query
topLevelQuery(org.apache.lucene.index.Term[] terms, org.apache.lucene.index.TermStates[] ctx, int[] docFreqs, int maxDoc)
java.lang.String
toString(java.lang.String field)
void
visit(org.apache.lucene.search.QueryVisitor visitor)
Methods inherited from class org.apache.lucene.search.Query
classHash, createWeight, sameClassAs, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
BlendedTermQuery
public BlendedTermQuery(org.apache.lucene.index.Term[] terms, float[] boosts)
-
-
Method Details
-
rewrite
public org.apache.lucene.search.Query rewrite(org.apache.lucene.index.IndexReader reader) throws java.io.IOException- Overrides:
rewrite
in classorg.apache.lucene.search.Query
- Throws:
java.io.IOException
-
topLevelQuery
protected abstract org.apache.lucene.search.Query topLevelQuery(org.apache.lucene.index.Term[] terms, org.apache.lucene.index.TermStates[] ctx, int[] docFreqs, int maxDoc) -
blend
protected void blend(org.apache.lucene.index.TermStates[] contexts, int maxDoc, org.apache.lucene.index.IndexReader reader) throws java.io.IOException- Throws:
java.io.IOException
-
getTerms
public java.util.List<org.apache.lucene.index.Term> getTerms() -
toString
public java.lang.String toString(java.lang.String field)- Specified by:
toString
in classorg.apache.lucene.search.Query
-
visit
public void visit(org.apache.lucene.search.QueryVisitor visitor)- Overrides:
visit
in classorg.apache.lucene.search.Query
-
equals
public boolean equals(java.lang.Object o)- Specified by:
equals
in classorg.apache.lucene.search.Query
-
hashCode
public int hashCode()- Specified by:
hashCode
in classorg.apache.lucene.search.Query
-
commonTermsBlendedQuery
@Deprecated public static BlendedTermQuery commonTermsBlendedQuery(org.apache.lucene.index.Term[] terms, float[] boosts, float maxTermFrequency)Deprecated.Since max_score optimization landed in 7.0, normal MultiMatchQuery will achieve the same result without any configuration. -
dismaxBlendedQuery
public static BlendedTermQuery dismaxBlendedQuery(org.apache.lucene.index.Term[] terms, float tieBreakerMultiplier) -
dismaxBlendedQuery
public static BlendedTermQuery dismaxBlendedQuery(org.apache.lucene.index.Term[] terms, float[] boosts, float tieBreakerMultiplier)
-