我正在尝试自定义规范化器“ mynormalizer”,并将其放入字段“ productDescription”中,
> curl -XPOST localhost:9200/intbee_v2104/card/_mapping -d '{
> "card":{
> "properties":{
> "productDescription":{
> "type":"text",
> "analyzer":"hanlp",
> "normalizer":"my_normalizer"
> }
> }
> }
> }'
但是会引发错误:
{“错误”:{“ root_cause”:[{“类型”:“ mapper_parsing_exception”,“原因”:“ [productDescription]的映射定义具有不受支持的参数:[normalizer:my_normalizer]”}],“ type” :“ mapper_parsing_exception”,“原因”:“ [productDescription]的映射定义具有不受支持的参数:[normalizer:my_normalizer]”},“ status”:400}
这是我的设置:
"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"
}
}
}
答案 0 :(得分:0)
规范化器仅适用于keyword
字段,不适用于text
。由于您还具有analyzer
设置,因此建议如下进行操作:
curl -XPOST localhost:9200/intbee_v2104/card/_mapping -d '{
"card":{
"properties":{
"productDescription":{
"type": "text",
"analyzer": "hanlp",
"fields": {
"keyword": {
"type":"keyword",
"normalizer":"my_normalizer"
}
}
}
}
} }'
经验法则:
text
字段=> analyzer
keyword
字段=> normalizer