0

I have been trying to implement snowball analyzer like functionality on one of my doc fields which is of type keyword. Like, for example plurals should be treated exactly like their singulars so that results are same for both.

Initially, I struggled setting analyzer on my field just to discover that fields of type keyword cannot have analyzers but normalizers. So, I tried setting a normalizer for snowball on those fields but it seems like my normalizer is not allowing the snowball filter (may be normalizers don't support the snowball filter)

I can't change the type of the field. I want to achieve functionality like if my input text matches restaurants it should treat it same as restaurant and give the results so that I don't have to add restaurants as a keyword to that field.

Can we achieve this through normalizers? I have gone through the elastic documentations and various posts but got no clue. Below is how I tried setting normalizer with the response from my elastic server.

PUT localhost:9200/db110/_settings

{
  "analysis": {
    "normalizer": {
      "snowball_normalizer": {
        "filter": ["lowercase","snowball" ]
      }
    },
    "filter" : {
        "snow" : {
            "type" : "snowball",
            "language" : "English"
        }
    }
  }

}

Response

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Custom normalizer [snowball_normalizer] may not use filter [snowball]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "Custom normalizer [snowball_normalizer] may not use filter [snowball]"
    },
    "status": 400
}
qwerty
  • 2,392
  • 3
  • 30
  • 55

1 Answers1

2

you can't do that! Snowball is a stemmer and it is used for fulltext search - e.g. text datatype, because it is a token filter, that manipulates every single token. With keyword datatype you create a single token for all the content of the field. How stemmer could works for keyword field, according you? Use stemmer without tokens has no sense. Normalizer for keyword fields are only lowercase and asciifolding. Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/normalizer.html

Lupanoide
  • 3,132
  • 20
  • 36