public abstract class CompletionQuery extends Query
Query
that match documents containing terms with a specified prefix
filtered by BitsProducer
. This should be used to query against any SuggestField
s
or ContextSuggestField
s of documents.
Use SuggestIndexSearcher.suggest(CompletionQuery, int, boolean)
to execute any query
that provides a concrete implementation of this query. Example below shows using this query
to retrieve the top 5 documents.
SuggestIndexSearcher searcher = new SuggestIndexSearcher(reader); TopSuggestDocs suggestDocs = searcher.suggest(query, 5);This query rewrites to an appropriate
CompletionQuery
depending on the
type (SuggestField
or ContextSuggestField
) of the field the query is run against.Modifier and Type | Field and Description |
---|---|
private BitsProducer |
filter
BitsProducer which is used to filter the document scope. |
private Term |
term
Term to query against
|
Modifier | Constructor and Description |
---|---|
protected |
CompletionQuery(Term term,
BitsProducer filter)
Creates a base Completion query against a
term
with a filter to scope the documents |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getField()
Returns the field name this query should
be run against
|
BitsProducer |
getFilter()
Returns a
BitsProducer . |
Term |
getTerm()
Returns the term to be queried against
|
Query |
rewrite(IndexReader reader)
Expert: called to re-write queries into primitive queries.
|
java.lang.String |
toString(java.lang.String field)
Prints a query to a string, with
field assumed to be the
default field and omitted. |
private void |
validate(java.lang.String termText) |
classHash, createWeight, equals, hashCode, sameClassAs, toString, visit
private final Term term
private final BitsProducer filter
BitsProducer
which is used to filter the document scope.protected CompletionQuery(Term term, BitsProducer filter)
term
with a filter
to scope the documentspublic BitsProducer getFilter()
BitsProducer
. Only suggestions matching the returned
bits will be returned.public java.lang.String getField()
public Term getTerm()
public Query rewrite(IndexReader reader) throws java.io.IOException
Query
public java.lang.String toString(java.lang.String field)
Query
field
assumed to be the
default field and omitted.private void validate(java.lang.String termText)