我正在尝试在 elasticsearch 的现有索引中添加分析器。
下面是代码 :-
curl -X POST "localhost:9200/existing_index_name/_mapping/_doc?pretty" -H 'Content-Type: application/json' -d'
{
"settings":{
"analysis":{
"analyzer":{
"analyzer_startswith":{
"tokenizer":"keyword",
"filter":["lowercase"]
}
}
}
}
}
'
以下是我遇到的错误:-
["type" : "mapper_parsing_exception",
"reason" : "Root mapping definition has unsupported parameters: [settings : {analysis={analyzer={analyzer_startswith={tokenizer=keyword, filter=[lowercase]}}}}]"
最佳答案
您需要调用 _settings
endpoint不是 _mapping
一个:
change this
|
v
curl -X POST "localhost:9200/existing_index_name/_settings?pretty" -H 'Content-Type: application/json' -d'{
"analysis": {
"analyzer": {
"analyzer_startswith": {
"tokenizer": "keyword",
"filter": [
"lowercase"
]
}
}
}
}
但是请注意,您需要先关闭索引:
curl -XPOST http://localhost:9200/existing_index_name/_close
然后更新设置后,需要再次打开
curl -XPOST http://localhost:9200/existing_index_name/_open
关于elasticsearch - 将分析器添加到 elasticsearch 6.3.1 中的现有索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58110981/