Search code examples
elasticsearchelasticsearch-7

Wrong results with Russian stemmer


I have index products with these analyzer settings. Search with query стекло returns empty result but with query стеклоы it works well.

PUT /products
{
  "settings": {
    "analysis": {
      "filter": {
        "russian_stop": {
          "type": "stop",
          "stopwords": "_russian_" 
        },
        "russian_stemmer": {
          "type": "stemmer",
          "language": "russian"
        },
        "russian_synonym": {
          "type": "synonym",
          "synonyms": [
            "айфон => iphone",
            "хонор => honor"
          ]
        }
      },
      "analyzer": {
        "ru_en": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "russian_stop",
            "russian_stemmer",
            "russian_synonym"
          ]
        }
      }
    }
  }
}

GET /products/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "query": "стекло",
            "operator": "and",
            "analyzer": "ru_en",
            "fuzziness": 0, 
            "fields": [
              "name",
              "category"
            ]
          }
        }
      ]
    }
  }
}

Solution

  • Add to index settings these mapping

    "mappings": {
        "properties": {
          "name": {
            "type": "text",
            "analyzer": "ru_en"
          }
        }
      }