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.

Czech analyzer

The built-in czech analyzer can be applied to a text field using the following command:

PUT /czech-index
{
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "czech"
      }
    }
  }
}

Stem exclusion

You can use stem_exclusion with this language analyzer using the following command:

PUT index_with_stem_exclusion_czech_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_czech_analyzer": {
          "type": "czech",
          "stem_exclusion": ["autorita", "schválení"]
        }
      }
    }
  }
}

Czech analyzer internals

The czech analyzer is built using the following components:

  • Tokenizer: standard

  • Token filters:

    • lowercase
    • stop (Czech)
    • keyword
    • stemmer (Czech)

Custom Czech analyzer

You can create a custom Czech analyzer using the following command:

PUT /czech-index
{
  "settings": {
    "analysis": {
      "filter": {
        "czech_stop": {
          "type": "stop",
          "stopwords": "_czech_"
        },
        "czech_stemmer": {
          "type": "stemmer",
          "language": "czech"
        },
        "czech_keywords": {
          "type":       "keyword_marker",
          "keywords":   [] 
        }
      },
      "analyzer": {
        "czech_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "czech_stop",
            "czech_keywords",
            "czech_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "czech_analyzer"
      }
    }
  }
}

Generated tokens

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

POST /czech-index/_analyze
{
  "field": "content",
  "text": "Studenti studují na českých univerzitách. Jejich čísla jsou 123456."
}

The response contains the generated tokens:

{
  "tokens": [
    {
      "token": "student",
      "start_offset": 0,
      "end_offset": 8,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "studuj",
      "start_offset": 9,
      "end_offset": 16,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "česk",
      "start_offset": 20,
      "end_offset": 27,
      "type": "<ALPHANUM>",
      "position": 3
    },
    {
      "token": "univerzit",
      "start_offset": 28,
      "end_offset": 40,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "čísl",
      "start_offset": 49,
      "end_offset": 54,
      "type": "<ALPHANUM>",
      "position": 6
    },
    {
      "token": "123456",
      "start_offset": 60,
      "end_offset": 66,
      "type": "<NUM>",
      "position": 8
    }
  ]
}
350 characters left

Have a question? .

Want to contribute? or .