我正在尝试在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]}}}}]"
答案 0 :(得分:0)
您需要呼叫_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
答案 1 :(得分:0)
您必须首先关闭索引 curl -XPOST“ http://localhost:9200/indexname/_open”
然后根据需要将_mappings更改为_settings
curl -XPUT "http://localhost:9200/indexname/_settings" -H 'Content-Type: application/json' -d'
{
"analysis": {
"analyzer": {
"analyzer_startswith": {
"tokenizer": "keyword",
"filter": [
"lowercase"
]
}
}
}
}'
打开索引 curl -XPOST“ http://localhost:9200/indexname/_open”