ASCII folding token filter

Converts alphabetic, numeric, and symbolic characters that are not in the Basic Latin Unicode block (first 127 ASCII characters) to their ASCII equivalent, if one exists. For example, the filter changes à to a.

This filter uses Lucene’s ASCIIFoldingFilter.

Example

The following analyze API request uses the asciifolding filter to drop the diacritical marks in açaí à la carte:

  1. GET /_analyze
  2. {
  3. "tokenizer" : "standard",
  4. "filter" : ["asciifolding"],
  5. "text" : "açaí à la carte"
  6. }

The filter produces the following tokens:

  1. [ acai, a, la, carte ]

Add to an analyzer

The following create index API request uses the asciifolding filter to configure a new custom analyzer.

  1. PUT /asciifold_example
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "standard_asciifolding": {
  7. "tokenizer": "standard",
  8. "filter": [ "asciifolding" ]
  9. }
  10. }
  11. }
  12. }
  13. }

Configurable parameters

preserve_original

(Optional, boolean) If true, emit both original tokens and folded tokens. Defaults to false.

Customize

To customize the asciifolding filter, duplicate it to create the basis for a new custom token filter. You can modify the filter using its configurable parameters.

For example, the following request creates a custom asciifolding filter with preserve_original set to true:

  1. PUT /asciifold_example
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "standard_asciifolding": {
  7. "tokenizer": "standard",
  8. "filter": [ "my_ascii_folding" ]
  9. }
  10. },
  11. "filter": {
  12. "my_ascii_folding": {
  13. "type": "asciifolding",
  14. "preserve_original": true
  15. }
  16. }
  17. }
  18. }
  19. }