1. Docs
  2. Cloaked Search
  3. Usage
  4. Configuration
  5. Filters - edge_ngram
  1. Docs
  2. Cloaked Search
  3. Usage
  4. Configuration
  5. 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 to 1.
  • max_gram (Optional, integer) Maximum character length of a gram. Defaults to 2.
  • preserve_original (Optional, Boolean) Emits original token when set to true. Defaults to false.

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 } } } }

Was this page helpful?

One sec... bot checking