Class MultipassTermFilteredPresearcher
- java.lang.Object
-
- org.apache.lucene.monitor.Presearcher
-
- org.apache.lucene.monitor.TermFilteredPresearcher
-
- org.apache.lucene.monitor.MultipassTermFilteredPresearcher
-
public class MultipassTermFilteredPresearcher extends TermFilteredPresearcher
A TermFilteredPresearcher that indexes queries multiple times, with terms collected from different routes through a querytree. Each route will produce a set of terms that are *sufficient* to select the query, and are indexed into a separate, suffixed field.Incoming documents are then converted to a set of Disjunction queries over each suffixed field, and these queries are combined into a conjunction query, such that the document's set of terms must match a term from each route.
This allows filtering out of documents that contain one half of a two-term phrase query, for example. The query
"hello world"
will be indexed twice, once under 'hello' and once under 'world'. A document containing the terms "hello there" would match the first field, but not the second, and so would not be selected for matching.The number of passes the presearcher makes is configurable. More passes will improve the selected/matched ratio, but will take longer to index and will use more RAM.
A minimum weight can we set for terms to be chosen for the second and subsequent passes. This allows users to avoid indexing stopwords, for example.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.monitor.TermFilteredPresearcher
TermFilteredPresearcher.BytesRefHashIterator, TermFilteredPresearcher.DocumentQueryBuilder
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.monitor.TermFilteredPresearcher
DEFAULT_WEIGHTOR
-
Fields inherited from class org.apache.lucene.monitor.Presearcher
NO_FILTERING
-
-
Constructor Summary
Constructors Constructor Description MultipassTermFilteredPresearcher(int passes)
Construct a new MultipassTermFilteredPresearcher usingTermFilteredPresearcher.DEFAULT_WEIGHTOR
MultipassTermFilteredPresearcher(int passes, float minWeight, TermWeightor weightor, List<CustomQueryHandler> queryHandlers, Set<String> filterFields)
Construct a new MultipassTermFilteredPresearcher
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Document
buildQueryDocument(QueryTree querytree)
Builds aDocument
from the terms extracted from a queryprotected TermFilteredPresearcher.DocumentQueryBuilder
getQueryBuilder()
Returns aTermFilteredPresearcher.DocumentQueryBuilder
for this presearcher-
Methods inherited from class org.apache.lucene.monitor.TermFilteredPresearcher
buildQuery, collectTerms, indexQuery
-
-
-
-
Constructor Detail
-
MultipassTermFilteredPresearcher
public MultipassTermFilteredPresearcher(int passes, float minWeight, TermWeightor weightor, List<CustomQueryHandler> queryHandlers, Set<String> filterFields)
Construct a new MultipassTermFilteredPresearcher- Parameters:
passes
- the number of times a query should be indexedminWeight
- the minimum weight a querytree should be advanced overweightor
- the TreeWeightor to usequeryHandlers
- a list of custom query handlersfilterFields
- a set of fields to use as filters
-
MultipassTermFilteredPresearcher
public MultipassTermFilteredPresearcher(int passes)
Construct a new MultipassTermFilteredPresearcher usingTermFilteredPresearcher.DEFAULT_WEIGHTOR
Note that this will be constructed with a minimum advance weight of zero
- Parameters:
passes
- the number of times a query should be indexed
-
-
Method Detail
-
getQueryBuilder
protected TermFilteredPresearcher.DocumentQueryBuilder getQueryBuilder()
Description copied from class:TermFilteredPresearcher
Returns aTermFilteredPresearcher.DocumentQueryBuilder
for this presearcher- Overrides:
getQueryBuilder
in classTermFilteredPresearcher
-
buildQueryDocument
public Document buildQueryDocument(QueryTree querytree)
Description copied from class:TermFilteredPresearcher
Builds aDocument
from the terms extracted from a query- Overrides:
buildQueryDocument
in classTermFilteredPresearcher
-
-