我正在尝试在 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"]
}
}
}
}
}
'
Run Code Online (Sandbox Code Playgroud)
以下是我收到的错误:-
["type" : "mapper_parsing_exception",
"reason" : "Root mapping definition has unsupported parameters: [settings : {analysis={analyzer={analyzer_startswith={tokenizer=keyword, filter=[lowercase]}}}}]"
Run Code Online (Sandbox Code Playgroud)
您需要调用端点_settings而不是_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"
]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但请注意,您需要首先关闭索引:
curl -XPOST http://localhost:9200/existing_index_name/_close
Run Code Online (Sandbox Code Playgroud)
然后更新设置后需要重新打开
curl -XPOST http://localhost:9200/existing_index_name/_open
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6627 次 |
| 最近记录: |