首先,我想设置ES的默认分析器,但失败了。然后根据其他问题和网站,我尝试设置一个索引的默认分析器。但也存在一些问题。
我已经配置了ik分析器,我可以设置一些字段的分析器,这是我的命令:
curl -XPUT localhost:9200/test
curl -XPUT localhost:9200/test/test/_mapping -d'{
"test":{
"properties":{
"name":{
"type":"string",
"analyzer":"ik"
}
}
}
}'
并得到消息:
{"acknowledged":true}
而且,这也是我的愿望。
但是,如果我尝试设置索引的默认分析器:
curl -XPOST localhost:9200/test1?pretty -d '{ "index":{
"analysis" : {
"analyzer" : {
"default" : {
"type" : "ik"
}
}
}
}
}'
我将收到错误消息:
{
"error" : {
"root_cause" : [ {
"type" : "index_creation_exception",
"reason" : "failed to create index"
} ],
"type" : "illegal_argument_exception",
"reason" : "no default analyzer configured"
},
"status" : 400
}
真奇怪,不是吗?
期待您对这个问题的意见。谢谢!:)