Link Search Menu Expand Document Documentation Menu

You're viewing version 2.18 of the OpenSearch documentation. This version is no longer maintained. For the latest version, see the current documentation. For information about OpenSearch version maintenance, see Release Schedule and Maintenance Policy.

Snowball token filter

The snowball token filter is a stemming filter based on the Snowball algorithm. It supports many languages and is more efficient and accurate than the Porter stemming algorithm.

Parameters

The snowball token filter can be configured with a language parameter that accepts the following values:

  • Arabic
  • Armenian
  • Basque
  • Catalan
  • Danish
  • Dutch
  • English (default)
  • Estonian
  • Finnish
  • French
  • German
  • German2
  • Hungarian
  • Italian
  • Irish
  • Kp
  • Lithuanian
  • Lovins
  • Norwegian
  • Porter
  • Portuguese
  • Romanian
  • Russian
  • Spanish
  • Swedish
  • Turkish

Example

The following example request creates a new index named my-snowball-index and configures an analyzer with a snowball filter:

PUT /my-snowball-index
{
  "settings": {
    "analysis": {
      "filter": {
        "my_snowball_filter": {
          "type": "snowball",
          "language": "English"
        }
      },
      "analyzer": {
        "my_snowball_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "my_snowball_filter"
          ]
        }
      }
    }
  }
}

Generated tokens

Use the following request to examine the tokens generated using the analyzer:

GET /my-snowball-index/_analyze
{
  "analyzer": "my_snowball_analyzer",
  "text": "running runners"
}

The response contains the generated tokens:

{
  "tokens": [
    {
      "token": "run",
      "start_offset": 0,
      "end_offset": 7,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "runner",
      "start_offset": 8,
      "end_offset": 15,
      "type": "<ALPHANUM>",
      "position": 1
    }
  ]
}
350 characters left

Have a question? .

Want to contribute? or .