Elision token filter

Removes specified elisions from the beginning of tokens. For example, you can use this filter to change l'avion to avion.

When not customized, the filter removes the following French elisions by default:

l', m', t', qu', n', s', j', d', c', jusqu', quoiqu', lorsqu', puisqu'

Customized versions of this filter are included in several of Elasticsearch’s built-in language analyzers:

This filter uses Lucene’s ElisionFilter.

Example

The following analyze API request uses the elision filter to remove j' from j’examine près du wharf:

  1. GET _analyze
  2. {
  3. "tokenizer" : "standard",
  4. "filter" : ["elision"],
  5. "text" : "j’examine près du wharf"
  6. }

The filter produces the following tokens:

  1. [ examine, près, du, wharf ]

Add to an analyzer

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

  1. PUT /elision_example
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "whitespace_elision": {
  7. "tokenizer": "whitespace",
  8. "filter": [ "elision" ]
  9. }
  10. }
  11. }
  12. }
  13. }

Configurable parameters

articles

(Required*, array of string) List of elisions to remove.

To be removed, the elision must be at the beginning of a token and be immediately followed by an apostrophe. Both the elision and apostrophe are removed.

For custom elision filters, either this parameter or articles_path must be specified.

articles_path

(Required*, string) Path to a file that contains a list of elisions to remove.

This path must be absolute or relative to the config location, and the file must be UTF-8 encoded. Each elision in the file must be separated by a line break.

To be removed, the elision must be at the beginning of a token and be immediately followed by an apostrophe. Both the elision and apostrophe are removed.

For custom elision filters, either this parameter or articles must be specified.

articles_case

(Optional, boolean) If true, the filter treats any provided elisions as case sensitive. Defaults to false.

Customize

To customize the elision 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 case-sensitive elision filter that removes the l', m', t', qu', n', s', and j' elisions:

  1. PUT /elision_case_sensitive_example
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "default": {
  7. "tokenizer": "whitespace",
  8. "filter": [ "elision_case_sensitive" ]
  9. }
  10. },
  11. "filter": {
  12. "elision_case_sensitive": {
  13. "type": "elision",
  14. "articles": [ "l", "m", "t", "qu", "n", "s", "j" ],
  15. "articles_case": true
  16. }
  17. }
  18. }
  19. }
  20. }