2
votes

I am trying to and custome normalizer 'mynormalizer' and put it into field 'productDescription',

>   curl -XPOST localhost:9200/intbee_v2104/card/_mapping -d '{
    >     "card":{
    >         "properties":{
    >             "productDescription":{
    >                 "type":"text",
    >                 "analyzer":"hanlp",
    >                 "normalizer":"my_normalizer"
    >             }
    >         }
    >     }
    > }'

but it throws an error:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Mapping definition for [productDescription] has unsupported parameters: [normalizer : my_normalizer]"}],"type":"mapper_parsing_exception","reason":"Mapping definition for [productDescription] has unsupported parameters: [normalizer : my_normalizer]"},"status":400}

Here is my setting:

"settings" : {
  "index" : {
    "number_of_shards" : "5",
    "provided_name" : "intbee_v2104",
    "creation_date" : "1533886907690",
    "analysis" : {
      "normalizer" : {
        "my_normalizer" : {
          "filter" : [
            "lowercase",
            "asciifolding"
          ],
          "type" : "custom"
        }
      }
    },
    "number_of_replicas" : "1",
    "uuid" : "f5Tdo1nfTo6UWlmwld9FFQ",
    "version" : {
      "created" : "5050099"
    }
  }
}
1

1 Answers

2
votes

Normalizers only work for keyword fields, not text. Since you also have an analyzer setting, I suggest doing it like below:

  curl -XPOST localhost:9200/intbee_v2104/card/_mapping -d '{
    "card":{
        "properties":{
            "productDescription":{
                "type": "text",
                "analyzer": "hanlp",
                "fields": {
                  "keyword": {
                    "type":"keyword",
                    "normalizer":"my_normalizer"
                  }
                }
            }
        }
    } }'

Rules of thumb:

  • text field => analyzer
  • keyword field => normalizer