如下mapping:
当user_name 索引空值的时候,报如下错误:
用什么方法可解决这个错误?
谢谢大家!
{
"settings": {
"analysis": {
"analyzer": {
"simple_analyzer": {
"tokenizer": "whitespace",
"filter": [
"simple_filter",
"lowercase"
]
},
"full_analyzer": {
"tokenizer": "whitespace",
"filter": [
"full_filter",
"lowercase"
]
}
},
"filter": {
"simple_filter": {
"type": "pinyin",
"keep_first_letter": true,
"keep_full_pinyin": false
},
"full_filter": {
"type": "pinyin",
"keep_first_letter": false,
"keep_full_pinyin": true,
"keep_none_chinese_in_first_letter": true
}
}
}
},
"mappings": {
"user": {
"properties": {
"user_id": {
"type": "keyword",
"doc_values": false
},
"user_name": {
"type": "keyword",
"fields": {
"suggest": {
"type": "completion"
},
"simple_pinyin": {
"type": "text",
"analyzer": "simple_analyzer"
},
"full_pinyin": {
"type": "text",
"analyzer": "full_analyzer"
}
}
},
"user_addr": {
"type": "text",
"analyzer": "ik_max_word",
"fields": {
"suggest": {
"type": "completion",
"analyzer": "ik_max_word"
}
}
}
}
}
}
}
当user_name 索引空值的时候,报如下错误:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "value must have a length > 0"
}
},
"status": 400
}
用什么方法可解决这个错误?
谢谢大家!
3 个回复
strglee
赞同来自: es_zoom
但是官方一直没有采纳 不知道原因 可能会在新版本修复吧
两个更改方案
1. 自己判断user_name是不是为空 如果为空,移除user_name字段
2. 自己更改源代码,编译(难度较大)
es_zoom
赞同来自:
配置后,错误消失。
如何配置这个suggest,当user_name为空时,不报错?
liuanxin
赞同来自:
如果想要抑制这个异常, 目前我的做法是在数据那里判断如果为 null 或空字符串就 set 一个 空格
完整的处理只能等官方 fix 这个 bug 了