Package org.apache.lucene.monitor
Class TermFilteredPresearcher
java.lang.Object
org.apache.lucene.monitor.Presearcher
org.apache.lucene.monitor.TermFilteredPresearcher
- Direct Known Subclasses:
MultipassTermFilteredPresearcher
Presearcher implementation that uses terms extracted from queries to index them in the Monitor,
and builds a disjunction from terms in a document to match them.
Handling of queries that do not support term extraction through the QueryVisitor API can be configured by passing a list of CustomQueryHandler implementations.
Filtering by additional fields can be configured by passing a set of field names. Documents
that contain values in those fields will only be checked against MonitorQuery instances
that have the same fieldname-value mapping in their metadata.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classImplements aBytesRefIteratorover aBytesRefHashprotected static interfaceConstructs a document disjunction from a set of terms -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final TermWeightorThe default TermWeightor, weighting by token lengthFields inherited from class org.apache.lucene.monitor.Presearcher
NO_FILTERING -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new TermFilteredPresearcher using the default term weightingTermFilteredPresearcher(TermWeightor weightor, List<CustomQueryHandler> customQueryHandlers, Set<String> filterFields) Creates a new TermFilteredPresearcher -
Method Summary
Modifier and TypeMethodDescriptionfinal QuerybuildQuery(LeafReader reader, BiPredicate<String, BytesRef> termAcceptor) Build a query for a Monitor's queryindex from a LeafReader over a set of documents to monitor.protected DocumentbuildQueryDocument(QueryTree querytree) Builds aDocumentfrom the terms extracted from a queryprotected Map<String, BytesRefHash> collectTerms(QueryTree querytree) Collects terms from aQueryTreeand maps them per-fieldReturns aTermFilteredPresearcher.DocumentQueryBuilderfor this presearcherfinal DocumentindexQuery(Query query, Map<String, String> metadata) Build a lucene Document to index the query in a Monitor's queryindex
-
Field Details
-
DEFAULT_WEIGHTOR
The default TermWeightor, weighting by token length -
ANYTOKEN_FIELD
- See Also:
-
ANYTOKEN
- See Also:
-
-
Constructor Details
-
TermFilteredPresearcher
public TermFilteredPresearcher()Creates a new TermFilteredPresearcher using the default term weighting -
TermFilteredPresearcher
public TermFilteredPresearcher(TermWeightor weightor, List<CustomQueryHandler> customQueryHandlers, Set<String> filterFields) Creates a new TermFilteredPresearcher- Parameters:
weightor- the TermWeightorcustomQueryHandlers- A list of custom query handlers to extract terms from non-core queriesfilterFields- A set of fields to filter on
-
-
Method Details
-
buildQuery
Description copied from class:PresearcherBuild a query for a Monitor's queryindex from a LeafReader over a set of documents to monitor.- Specified by:
buildQueryin classPresearcher- Parameters:
reader- aLeafReaderover the input documentstermAcceptor- a predicate indicating if a term should be added to the query- Returns:
- a Query to run over a Monitor's queryindex
-
getQueryBuilder
Returns aTermFilteredPresearcher.DocumentQueryBuilderfor this presearcher -
indexQuery
Description copied from class:PresearcherBuild a lucene Document to index the query in a Monitor's queryindex- Specified by:
indexQueryin classPresearcher- Parameters:
query- the Query to indexmetadata- a Map of arbitrary query metadata- Returns:
- a lucene Document to add to the queryindex
-
buildQueryDocument
Builds aDocumentfrom the terms extracted from a query -
collectTerms
Collects terms from aQueryTreeand maps them per-field
-