Package org.apache.lucene.monitor
Class RegexpQueryHandler
java.lang.Object
org.apache.lucene.monitor.RegexpQueryHandler
- All Implemented Interfaces:
CustomQueryHandler
A query handler implementation that matches Regexp queries by indexing regex terms by their
longest static substring, and generates ngrams from Document tokens to match them.
This implementation will filter out more wildcard queries than TermFilteredPresearcher, at the expense of longer document build times. Which one is more performant will depend on the type and number of queries registered in the Monitor, and the size of documents to be monitored. Profiling is recommended.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new RegexpQueryHandler using default settingsRegexpQueryHandler
(int maxTokenSize) Creates a new RegexpQueryHandler with a maximum token sizeRegexpQueryHandler
(String ngramSuffix, int maxTokenSize, String wildcardToken, Set<String> excludedFields) Creates a new RegexpQueryHandler -
Method Summary
Modifier and TypeMethodDescriptionhandleQuery
(Query q, TermWeightor termWeightor) Builds aQueryTree
node from a querywrapTermStream
(String field, TokenStream ts) Adds additional processing to theTokenStream
over a document's terms index
-
Field Details
-
DEFAULT_NGRAM_SUFFIX
The default suffix with which to mark ngrams- See Also:
-
DEFAULT_MAX_TOKEN_SIZE
public static final int DEFAULT_MAX_TOKEN_SIZEThe default maximum length of an input token before ANYTOKENS are generated- See Also:
-
DEFAULT_WILDCARD_TOKEN
The default token to emit if a term is longer than MAX_TOKEN_SIZE- See Also:
-
-
Constructor Details
-
RegexpQueryHandler
public RegexpQueryHandler(String ngramSuffix, int maxTokenSize, String wildcardToken, Set<String> excludedFields) Creates a new RegexpQueryHandler- Parameters:
ngramSuffix
- the suffix with which to mark ngramsmaxTokenSize
- the maximum length of an input token before WILDCARD tokens are generatedwildcardToken
- the token to emit if a token is longer than maxTokenSize in lengthexcludedFields
- a Set of fields to ignore when generating ngrams
-
RegexpQueryHandler
public RegexpQueryHandler()Creates a new RegexpQueryHandler using default settings -
RegexpQueryHandler
public RegexpQueryHandler(int maxTokenSize) Creates a new RegexpQueryHandler with a maximum token size- Parameters:
maxTokenSize
- the maximum length of an input token before WILDCARD tokens are generated
-
-
Method Details
-
wrapTermStream
Description copied from interface:CustomQueryHandler
Adds additional processing to theTokenStream
over a document's terms index- Specified by:
wrapTermStream
in interfaceCustomQueryHandler
-
handleQuery
Description copied from interface:CustomQueryHandler
Builds aQueryTree
node from a query- Specified by:
handleQuery
in interfaceCustomQueryHandler
-