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>
-
public class SpanMultiTermQueryWrapper<Q extends MultiTermQuery> extends SpanQuery
Wraps anyMultiTermQueryas aSpanQuery, so it can be nested within other SpanQuery classes.The query is rewritten by default to a
SpanOrQuerycontaining 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 Classes Modifier and Type Class Description static classSpanMultiTermQueryWrapper.SpanRewriteMethodAbstract class that defines how the query is rewritten.static classSpanMultiTermQueryWrapper.TopTermsSpanBooleanQueryRewriteA 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
Fields Modifier and Type Field Description protected Qquerystatic SpanMultiTermQueryWrapper.SpanRewriteMethodSCORING_SPAN_QUERY_REWRITEA 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 Constructor Description SpanMultiTermQueryWrapper(Q query)Create a new SpanMultiTermQueryWrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SpanWeightcreateWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)booleanequals(Object other)StringgetField()Returns the name of the field matched by this query.SpanMultiTermQueryWrapper.SpanRewriteMethodgetRewriteMethod()Expert: returns the rewriteMethodQuerygetWrappedQuery()Returns the wrapped queryinthashCode()Queryrewrite(IndexSearcher indexSearcher)voidsetRewriteMethod(SpanMultiTermQueryWrapper.SpanRewriteMethod rewriteMethod)Expert: sets the rewrite method.StringtoString(String field)voidvisit(QueryVisitor visitor)-
Methods inherited from class org.apache.lucene.queries.spans.SpanQuery
getTermStates, getTermStates
-
Methods inherited from class org.apache.lucene.search.Query
classHash, rewrite, sameClassAs, toString
-
-
-
-
Field Detail
-
query
protected final Q extends MultiTermQuery query
-
SCORING_SPAN_QUERY_REWRITE
public static final SpanMultiTermQueryWrapper.SpanRewriteMethod 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.
-
-
Constructor Detail
-
SpanMultiTermQueryWrapper
public SpanMultiTermQueryWrapper(Q query)
Create a new SpanMultiTermQueryWrapper.- Parameters:
query- Query to wrap.
-
-
Method Detail
-
getRewriteMethod
public final SpanMultiTermQueryWrapper.SpanRewriteMethod getRewriteMethod()
Expert: returns the rewriteMethod
-
setRewriteMethod
public final void setRewriteMethod(SpanMultiTermQueryWrapper.SpanRewriteMethod rewriteMethod)
Expert: sets the rewrite method. This only makes sense to be a span rewrite method.
-
getField
public String 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
public Query getWrappedQuery()
Returns the wrapped query
-
rewrite
public Query rewrite(IndexSearcher indexSearcher) throws IOException
- Overrides:
rewritein classQuery- Throws:
IOException
-
visit
public void visit(QueryVisitor visitor)
-
-