Set Index Analyzer as Default

At first I wanted to install the default analyzer ES and failed. And then, on other issues and websites, I try to set the default analyzer for a single index. But there are some problems.

I configured the ik analyzer and I can install the field analyzer, here is my command:

curl -XPUT localhost:9200/test

 curl -XPUT localhost:9200/test/test/_mapping -d'{ "test":{ "properties":{ "name":{ "type":"string", "analyzer":"ik" } } } }' 

and get a message:

 {"acknowledged":true} 

also, it works as my wish.

but if I try to install the default index parser:

 curl -XPOST localhost:9200/test1?pretty -d '{ "index":{ "analysis" : { "analyzer" : { "default" : { "type" : "ik" } } } } }' 

An error message will appear:

 { "error" : { "root_cause" : [ { "type" : "index_creation_exception", "reason" : "failed to create index" } ], "type" : "illegal_argument_exception", "reason" : "no default analyzer configured" }, "status" : 400 } 

So weird, isn't it? We look forward to hearing your views on this issue. Thank you :)

+6
source share
1 answer

You are almost there, you are just missing /_settings in your path. Do it like that. Also note that you need to close the index first , and then reopen it after updating the analyzers.

 // close index curl -XPOST 'localhost:9200/test1/_close' add this to the path | v curl -XPUT localhost:9200/test1/_settings?pretty -d '{ "index":{ "analysis" : { "analyzer" : { "default" : { "type" : "ik" } } } } }' // re-open index curl -XPOST 'localhost:9200/test1/_open' 
+5
source

All Articles