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 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 Classes
Modifier and Type
Class
Description
`static class`
`SpanMultiTermQueryWrapper.SpanRewriteMethod`
Abstract class that defines how the query is rewritten.
`static final class`
`SpanMultiTermQueryWrapper.TopTermsSpanBooleanQueryRewrite`
A rewrite method that first translates each term into a SpanTermQuery in a `BooleanClause.Occur.SHOULD` clause in a BooleanQuery, and keeps the scores as computed by the query.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final Q`
`query`
`static final SpanMultiTermQueryWrapper.SpanRewriteMethod`
`SCORING_SPAN_QUERY_REWRITE`
A rewrite method that first translates each term into a SpanTermQuery in a `BooleanClause.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

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.
`final SpanMultiTermQueryWrapper.SpanRewriteMethod`
`getRewriteMethod()`
Expert: returns the rewriteMethod
`Query`
`getWrappedQuery()`
Returns the wrapped query
`int`
`hashCode()`
`Query`
`rewrite(IndexSearcher indexSearcher)`
`final 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, sameClassAs, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### 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 a `BooleanClause.Occur.SHOULD` clause in a BooleanQuery, and keeps the scores as computed by the query.

See Also:
  - `setRewriteMethod(org.apache.lucene.queries.spans.SpanMultiTermQueryWrapper.SpanRewriteMethod)`

## Constructor Details

### SpanMultiTermQueryWrapper

public SpanMultiTermQueryWrapper(Q query)
Create a new SpanMultiTermQueryWrapper.

Parameters:
  `query` - Query to wrap.

## Method Details

### 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.

Specified by:
  `getField` in class `SpanQuery`

### createWeight

public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException

Specified by:
  `createWeight` in class `SpanQuery`
Throws:
  `IOException`

### getWrappedQuery

public Query getWrappedQuery()
Returns the wrapped query

### toString

public String toString(String field)

Specified by:
  `toString` in class `Query`

### rewrite

public Query rewrite(IndexSearcher indexSearcher) throws IOException

Overrides:
  `rewrite` in class `Query`
Throws:
  `IOException`

### visit

public void visit(QueryVisitor visitor)

Specified by:
  `visit` in class `Query`

### hashCode

public int hashCode()

Specified by:
  `hashCode` in class `Query`

### equals

public boolean equals(Object other)

Specified by:
  `equals` in class `Query`