Package org.apache.lucene.queries.spans
Class SpanMultiTermQueryWrapper<Q extends MultiTermQuery>
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.queries.spans.SpanQuery
org.apache.lucene.queries.spans.SpanMultiTermQueryWrapper<Q>
Wraps any
MultiTermQuery as a SpanQuery, so it can be nested within other
SpanQuery classes.
The query is rewritten by default to a SpanOrQuery containing the expanded terms, but
this can be customized.
Example:
WildcardQuery wildcard = new WildcardQuery(new Term("field", "bro?n")); SpanQuery spanWildcard = new SpanMultiTermQueryWrapper<WildcardQuery>(wildcard); // do something with spanWildcard, such as use it in a SpanFirstQuery
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA rewrite method that translates each term into a SpanTermQuery within aSpanOrQuery, but retains only the most frequent terms so it will not overflow the boolean max clause count.static classAbstract class that defines how the query is rewritten.static final classA rewrite method that first translates each term into a SpanTermQuery in aBooleanClause.Occur.SHOULDclause in a BooleanQuery, and keeps the scores as computed by the query. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Qstatic final SpanMultiTermQueryWrapper.SpanRewriteMethodA rewrite method that first translates each term into a SpanTermQuery in aBooleanClause.Occur.SHOULDclause in a BooleanQuery, and keeps the scores as computed by the query. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) booleangetField()Returns the name of the field matched by this query.Expert: returns the rewriteMethodReturns the wrapped queryinthashCode()rewrite(IndexSearcher indexSearcher) final voidsetRewriteMethod(SpanMultiTermQueryWrapper.SpanRewriteMethod rewriteMethod) Expert: sets the rewrite method.voidvisit(QueryVisitor visitor) Methods inherited from class org.apache.lucene.queries.spans.SpanQuery
getTermStates, getTermStatesMethods inherited from class org.apache.lucene.search.Query
classHash, sameClassAs, toString
-
Field Details
-
query
-
SCORING_SPAN_QUERY_REWRITE
A rewrite method that first translates each term into a SpanTermQuery in aBooleanClause.Occur.SHOULDclause in a BooleanQuery, and keeps the scores as computed by the query.- See Also:
-
-
Constructor Details
-
SpanMultiTermQueryWrapper
Create a new SpanMultiTermQueryWrapper.- Parameters:
query- Query to wrap.
-
-
Method Details
-
getRewriteMethod
Expert: returns the rewriteMethod -
setRewriteMethod
Expert: sets the rewrite method. This only makes sense to be a span rewrite method. -
getField
Description copied from class:SpanQueryReturns the name of the field matched by this query. -
createWeight
public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException - Specified by:
createWeightin classSpanQuery- Throws:
IOException
-
getWrappedQuery
Returns the wrapped query -
toString
-
rewrite
- Overrides:
rewritein classQuery- Throws:
IOException
-
visit
-
hashCode
public int hashCode() -
equals
-