Class CompletionQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.suggest.document.CompletionQuery
- Direct Known Subclasses:
ContextQuery
,PrefixCompletionQuery
,RegexCompletionQuery
Abstract
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.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Constructor Summary
ModifierConstructorDescriptionprotected
CompletionQuery
(Term term, BitsProducer filter) Creates a base Completion query against aterm
with afilter
to scope the documents -
Method Summary
Modifier and TypeMethodDescriptiongetField()
Returns the field name this query should be run againstReturns aBitsProducer
.getTerm()
Returns the term to be queried againstrewrite
(IndexReader reader) Methods inherited from class org.apache.lucene.search.Query
classHash, createWeight, equals, hashCode, sameClassAs, toString, visit
-
Constructor Details
-
CompletionQuery
Creates a base Completion query against aterm
with afilter
to scope the documents
-
-
Method Details
-
getFilter
Returns aBitsProducer
. Only suggestions matching the returned bits will be returned. -
getField
Returns the field name this query should be run against -
getTerm
Returns the term to be queried against -
rewrite
- Overrides:
rewrite
in classQuery
- Throws:
IOException
-
toString
-