- Docs
- Cloaked Search
- Usage
- Configuration
- Filters - edge_ngram
Edge N-gram token filter
Forms an N-gram of a specified length from the beginning of a token.
For example, you can use the edge_ngram token filter to change quick to qu.
Add to an analyzer
edge_ngram can be added to any analyzer as a filter.
JSON"analyzer": { "longer_autocomplete_analyzer": { "type": "custom", "tokenizer": "standard", "filter": ["edge_ngram"] } }
Configurable parameters
min_gram(Optional, integer) Minimum character length of a gram. Defaults to1.max_gram(Optional, integer) Maximum character length of a gram. Defaults to2.preserve_original(Optional, Boolean) Emits original token when set to true. Defaults tofalse.
For example a 3-5 edge-ngram could be configured and used like this:
JSON"settings": { "analysis": { "analyzer": { "custom_analyzer": { "type": "custom", "filter": ["3_5_edgegrams"] } }, "filter": { "3_5_edgegrams": { "type": "edge_ngram", "min_gram": 3, "max_gram": 5 } } } }