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 final int`
`DEFAULT_MAX_TOKEN_SIZE`
The default maximum length of an input token before ANYTOKENS are generated
`static final String`
`DEFAULT_NGRAM_SUFFIX`
The default suffix with which to mark ngrams
`static final 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 settings
`RegexpQueryHandler(int maxTokenSize)`
Creates a new RegexpQueryHandler with a maximum token size
`RegexpQueryHandler(String ngramSuffix, int maxTokenSize, String wildcardToken, Set<String> excludedFields)`
Creates a new RegexpQueryHandler

## Method Summary

Modifier and Type
Method
Description
`QueryTree`
`handleQuery(Query q, TermWeightor termWeightor)`
Builds a `QueryTree` node from a query
`TokenStream`
`wrapTermStream(String field, TokenStream ts)`
Adds additional processing to the `TokenStream` over a document's terms index

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### 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 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 ngrams
  `maxTokenSize` - the maximum length of an input token before WILDCARD tokens are generated
  `wildcardToken` - the token to emit if a token is longer than maxTokenSize in length
  `excludedFields` - 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

public TokenStream wrapTermStream(String field, TokenStream ts)
Description copied from interface: `CustomQueryHandler`
Adds additional processing to the `TokenStream` over a document's terms index

Specified by:
  `wrapTermStream` in interface `CustomQueryHandler`

### handleQuery

public QueryTree handleQuery(Query q, TermWeightor termWeightor)
Description copied from interface: `CustomQueryHandler`
Builds a `QueryTree` node from a query

Specified by:
  `handleQuery` in interface `CustomQueryHandler`