Package org.apache.lucene.monitor
Class RegexpQueryHandler
- java.lang.Object
-
- org.apache.lucene.monitor.RegexpQueryHandler
-
- All Implemented Interfaces:
CustomQueryHandler
public class RegexpQueryHandler extends Object implements 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
Fields Modifier and Type Field Description static int
DEFAULT_MAX_TOKEN_SIZE
The default maximum length of an input token before ANYTOKENS are generatedstatic String
DEFAULT_NGRAM_SUFFIX
The default suffix with which to mark ngramsstatic String
DEFAULT_WILDCARD_TOKEN
The default token to emit if a term is longer than MAX_TOKEN_SIZE
-
Constructor Summary
Constructors Constructor Description RegexpQueryHandler()
Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryTree
handleQuery(Query q, TermWeightor termWeightor)
Builds aQueryTree
node from a queryTokenStream
wrapTermStream(String field, TokenStream ts)
Adds additional processing to theTokenStream
over a document's terms index
-
-
-
Field Detail
-
DEFAULT_NGRAM_SUFFIX
public static final String DEFAULT_NGRAM_SUFFIX
The default suffix with which to mark ngrams- See Also:
- Constant Field Values
-
DEFAULT_MAX_TOKEN_SIZE
public static final int DEFAULT_MAX_TOKEN_SIZE
The default maximum length of an input token before ANYTOKENS are generated- See Also:
- Constant Field Values
-
DEFAULT_WILDCARD_TOKEN
public static final String DEFAULT_WILDCARD_TOKEN
The default token to emit if a term is longer than MAX_TOKEN_SIZE- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
wrapTermStream
public TokenStream wrapTermStream(String field, TokenStream ts)
Description copied from interface:CustomQueryHandler
Adds additional processing to theTokenStream
over a document's terms index- Specified by:
wrapTermStream
in interfaceCustomQueryHandler
-
handleQuery
public QueryTree handleQuery(Query q, TermWeightor termWeightor)
Description copied from interface:CustomQueryHandler
Builds aQueryTree
node from a query- Specified by:
handleQuery
in interfaceCustomQueryHandler
-
-