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
Modifier and TypeClassDescriptionstatic class
Abstract class that defines how the query is rewritten.static final class
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
Modifier and TypeFieldDescriptionprotected final Q
static final SpanMultiTermQueryWrapper.SpanRewriteMethod
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
-
Method Summary
Modifier and TypeMethodDescriptioncreateWeight
(IndexSearcher searcher, ScoreMode scoreMode, float boost) boolean
getField()
Returns the name of the field matched by this query.Expert: returns the rewriteMethodReturns the wrapped queryint
hashCode()
rewrite
(IndexReader reader) final void
setRewriteMethod
(SpanMultiTermQueryWrapper.SpanRewriteMethod rewriteMethod) Expert: sets the rewrite method.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, sameClassAs, toString
-
Field Details
-
query
-
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 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: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
Returns the wrapped query -
toString
-
rewrite
- Overrides:
rewrite
in classQuery
- Throws:
IOException
-
visit
-
hashCode
public int hashCode() -
equals
-