public class TermFilteredPresearcher extends Presearcher
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.| Modifier and Type | Class and Description |
|---|---|
protected class |
TermFilteredPresearcher.BytesRefHashIterator
Implements a
BytesRefIterator over a BytesRefHash |
protected static interface |
TermFilteredPresearcher.DocumentQueryBuilder
Constructs a document disjunction from a set of terms
|
| Modifier and Type | Field and Description |
|---|---|
(package private) static java.lang.String |
ANYTOKEN |
(package private) static java.lang.String |
ANYTOKEN_FIELD |
static TermWeightor |
DEFAULT_WEIGHTOR
The default TermWeightor, weighting by token length
|
private QueryAnalyzer |
extractor |
private java.util.Set<java.lang.String> |
filterFields |
(package private) static FieldType |
QUERYFIELDTYPE |
private java.util.List<CustomQueryHandler> |
queryHandlers |
private TermWeightor |
weightor |
NO_FILTERING| Constructor and Description |
|---|
TermFilteredPresearcher()
Creates a new TermFilteredPresearcher using the default term weighting
|
TermFilteredPresearcher(TermWeightor weightor,
java.util.List<CustomQueryHandler> customQueryHandlers,
java.util.Set<java.lang.String> filterFields)
Creates a new TermFilteredPresearcher
|
| Modifier and Type | Method and Description |
|---|---|
private Query |
buildFilterClause(LeafReader reader,
java.lang.String field) |
private Query |
buildFilterFields(LeafReader reader) |
Query |
buildQuery(LeafReader reader,
java.util.function.BiPredicate<java.lang.String,BytesRef> termAcceptor)
Build a query for a Monitor's queryindex from a LeafReader over a set of documents to monitor.
|
protected Document |
buildQueryDocument(QueryTree querytree)
Builds a
Document from the terms extracted from a query |
protected java.util.Map<java.lang.String,BytesRefHash> |
collectTerms(QueryTree querytree)
Collects terms from a
QueryTree and maps them per-field |
protected TermFilteredPresearcher.DocumentQueryBuilder |
getQueryBuilder()
Returns a
TermFilteredPresearcher.DocumentQueryBuilder for this presearcher |
Document |
indexQuery(Query query,
java.util.Map<java.lang.String,java.lang.String> metadata)
Build a lucene Document to index the query in a Monitor's queryindex
|
public static final TermWeightor DEFAULT_WEIGHTOR
private final QueryAnalyzer extractor
private final TermWeightor weightor
private final java.util.Set<java.lang.String> filterFields
private final java.util.List<CustomQueryHandler> queryHandlers
static final java.lang.String ANYTOKEN_FIELD
static final java.lang.String ANYTOKEN
static final FieldType QUERYFIELDTYPE
public TermFilteredPresearcher()
public TermFilteredPresearcher(TermWeightor weightor, java.util.List<CustomQueryHandler> customQueryHandlers, java.util.Set<java.lang.String> filterFields)
weightor - the TermWeightorcustomQueryHandlers - A list of custom query handlers to extract terms from non-core queriesfilterFields - A set of fields to filter onpublic final Query buildQuery(LeafReader reader, java.util.function.BiPredicate<java.lang.String,BytesRef> termAcceptor)
PresearcherbuildQuery in class Presearcherreader - a LeafReader over the input documentstermAcceptor - a predicate indicating if a term should be added to the queryprivate Query buildFilterFields(LeafReader reader) throws java.io.IOException
java.io.IOExceptionprivate Query buildFilterClause(LeafReader reader, java.lang.String field) throws java.io.IOException
java.io.IOExceptionprotected TermFilteredPresearcher.DocumentQueryBuilder getQueryBuilder()
TermFilteredPresearcher.DocumentQueryBuilder for this presearcherpublic final Document indexQuery(Query query, java.util.Map<java.lang.String,java.lang.String> metadata)
PresearcherindexQuery in class Presearcherquery - the Query to indexmetadata - a Map of arbitrary query metadataprotected Document buildQueryDocument(QueryTree querytree)
Document from the terms extracted from a queryprotected java.util.Map<java.lang.String,BytesRefHash> collectTerms(QueryTree querytree)
QueryTree and maps them per-field