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 anyMultiTermQuery
as aSpanQuery
, 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 Classes Modifier and Type Class Description static class
SpanMultiTermQueryWrapper.SpanRewriteMethod
Abstract class that defines how the query is rewritten.static class
SpanMultiTermQueryWrapper.TopTermsSpanBooleanQueryRewrite
A rewrite method that first translates each term into a SpanTermQuery in aBooleanClause.Occur.SHOULD
clause in a BooleanQuery, and keeps the scores as computed by the query.
-
Field Summary
Fields Modifier and Type Field Description protected Q
query
static SpanMultiTermQueryWrapper.SpanRewriteMethod
SCORING_SPAN_QUERY_REWRITE
A rewrite method that first translates each term into a SpanTermQuery in aBooleanClause.Occur.SHOULD
clause 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 SpanWeight
createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)
boolean
equals(Object other)
String
getField()
Returns the name of the field matched by this query.SpanMultiTermQueryWrapper.SpanRewriteMethod
getRewriteMethod()
Expert: returns the rewriteMethodQuery
getWrappedQuery()
Returns the wrapped queryint
hashCode()
Query
rewrite(IndexSearcher indexSearcher)
void
setRewriteMethod(SpanMultiTermQueryWrapper.SpanRewriteMethod rewriteMethod)
Expert: sets the rewrite method.String
toString(String field)
void
visit(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.SHOULD
clause 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:SpanQuery
Returns the name of the field matched by this query.
-
createWeight
public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException
- Specified by:
createWeight
in classSpanQuery
- Throws:
IOException
-
getWrappedQuery
public Query getWrappedQuery()
Returns the wrapped query
-
rewrite
public Query rewrite(IndexSearcher indexSearcher) throws IOException
- Overrides:
rewrite
in classQuery
- Throws:
IOException
-
visit
public void visit(QueryVisitor visitor)
-
-