我试图创建一个自定义的分析器的索引,使令牌和生成使用此自定义索引。
我试着做了以下几件事
PUT /index_name/_settings
{
"analysis" : {
"analyzer":{
"custom_analyzer_name": {
"type": "custom",
"tokenizer": "standard",
"char_filter": [
"html_strip"
],
"filter": [
"lowercase",
"stop"
]
}
}
}
}
这给了我这个错误
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Can't update non dynamic settings [[index.analysis.analyzer.custom_analyzer_name.char_filter, index.analysis.analyzer.custom_analyzer_name.filter, index.analysis.analyzer.custom_analyzer_name.type, index.analysis.analyzer.custom_analyzer_name.tokenizer]] for open indices [[index_name/Zd4fisCyR6alpkzj-6uSgQ]]"
}
],
"type": "illegal_argument_exception",
"reason": "Can't update non dynamic settings [[index.analysis.analyzer.custom_analyzer_name.char_filter, index.analysis.analyzer.custom_analyzer_name.filter, index.analysis.analyzer.custom_analyzer_name.type, index.analysis.analyzer.custom_analyzer_name.tokenizer]] for open indices [[index_name/Zd4fisCyR6alpkzj-6uSgQ]]"
},
"status": 400
}
我也试着这样创建分析器
PUT /index_name
{
"settings": {
"analysis": {
"analyzer": {
"custom_analyzer_name": {
"type": "custom",
"tokenizer": "standard",
"char_filter": [
"html_strip"
],
"filter": [
"lowercase",
"stop"
]
}
}
}
}
}
但这给了我以下错误
{
"error": {
"root_cause": [
{
"type": "resource_already_exists_exception",
"reason": "index [index_name/Zd4fisCyR6alpkzj-6uSgQ] already exists",
"index_uuid": "Zd4fisCyR6alpkzj-6uSgQ",
"index": "index_name"
}
],
"type": "resource_already_exists_exception",
"reason": "index [index_name/Zd4fisCyR6alpkzj-6uSgQ] already exists",
"index_uuid": "Zd4fisCyR6alpkzj-6uSgQ",
"index": "index_name"
},
"status": 400
}
如何在Elasticsearch索引中正确创建和分配自定义分析器?
1条答案
按热度按时间kuuvgm7e1#
从您得到的错误判断,
index_name
已经存在,因此除非先删除它,否则无法重新创建它。如果您无法删除它,但只想修改分析器,则可以先关闭索引,然后重新打开它: