将同义词分析器添加到弹性搜索索引 [英] Add synonym analyzer to elasticsearch index
问题描述
{
analysis:{
analyzer:{
synonym:{
tokenizer:whitespace,
filter:[synonym]
}
},
过滤器:{
同义词:{
type:synonym,
peers_path synonym.txt,
ignore_case:true
}
}
}
}
我收到错误
{error:IndexAlreadyExistsException [[nuxeo]已经存在],状态:400}
所以我必须删除索引之前添加或刷新同义词文件不是非常聪明的
添加分析器的简单方法?还是至少刷新一下?谢谢
您需要先关闭索引,更新分析器设置,然后打开索引。这是更新现有分析仪设置的唯一方法。请注意,更改在使用索引但未使用的分析仪时只能使用
curl -XPOST'localhost:9200 / schoolrecords / _close'
curl -XPUT'localhost:9200 / schoolrecords / _settings'-d'{
analysis:{
analyzer:{
synonym:{
tokenizer:whitespace,
filter:[synonym]
}
},
filter:{
同义词:{
type:synonym,
peers_path:synonym.txt,
ignore_case:true
}
}
}
}'
curl -XPOST'localhost:9200 / schoolrecords / _open'
i have an existing elasticsearch index and i would like to add a analyzer but when i execute this command
{
"analysis" : {
"analyzer" : {
"synonym" : {
"tokenizer" : "whitespace",
"filter" : ["synonym"]
}
},
"filter" : {
"synonym" : {
"type" : "synonym",
"synonyms_path" : "synonym.txt",
"ignore_case" : true
}
}
}
}
i get an error
{"error":"IndexAlreadyExistsException[[nuxeo] already exists]","status":400}
so i have to remove the index before add or refresh the synonym file is not very smart A simply way exist to add a analyzer ? or at least to refresh it? thanks
You need to first close the index , update analyzer settings and then open the index. That is the only way to update existing analyzer settings. Note that it only makes sense to change analyzers which are not used while indexing but used
curl -XPOST 'localhost:9200/schoolrecords/_close'
curl -XPUT 'localhost:9200/schoolrecords/_settings' -d '{
"analysis" : {
"analyzer" : {
"synonym" : {
"tokenizer" : "whitespace",
"filter" : ["synonym"]
}
},
"filter" : {
"synonym" : {
"type" : "synonym",
"synonyms_path" : "synonym.txt",
"ignore_case" : true
}
}
}
}'
curl -XPOST 'localhost:9200/schoolrecords/_open'
这篇关于将同义词分析器添加到弹性搜索索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!