Stemmer token filter

Provides algorithmic stemming for several languages, some with additional variants. For a list of supported languages, see the language parameter.

When not customized, the filter uses the porter stemming algorithm for English.

Example

The following analyze API request uses the stemmer filter’s default porter stemming algorithm to stem the foxes jumping quickly to the fox jump quickli:

  1. GET /_analyze
  2. {
  3. "tokenizer": "standard",
  4. "filter": [ "stemmer" ],
  5. "text": "the foxes jumping quickly"
  6. }

The filter produces the following tokens:

  1. [ the, fox, jump, quickli ]

Add to an analyzer

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

  1. PUT /my-index-000001
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "my_analyzer": {
  7. "tokenizer": "whitespace",
  8. "filter": [ "stemmer" ]
  9. }
  10. }
  11. }
  12. }
  13. }

Configurable parameters

language

(Optional, string) Language-dependent stemming algorithm used to stem tokens. If both this and the name parameter are specified, the language parameter argument is used.

Valid values for language

Valid values are sorted by language. Defaults to english. Recommended algorithms are bolded.

name

An alias for the language parameter. If both this and the language parameter are specified, the language parameter argument is used.

Customize

To customize the stemmer 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 stemmer filter that stems words using the light_german algorithm:

  1. PUT /my-index-000001
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "my_analyzer": {
  7. "tokenizer": "standard",
  8. "filter": [
  9. "lowercase",
  10. "my_stemmer"
  11. ]
  12. }
  13. },
  14. "filter": {
  15. "my_stemmer": {
  16. "type": "stemmer",
  17. "language": "light_german"
  18. }
  19. }
  20. }
  21. }
  22. }