elasticsearch 在Elasticsearch中对同义词进行等分
我们可以在elasticsearch中对原始字符串和同义词进行同等评分吗 例如,我创建了同义词文件: 私人 有限公司 我使用同义标记过滤器创建了一个索引。然后我索引了两个文档:
elasticsearch 在Elasticsearch中对同义词进行等分,
elasticsearch,filter,tokenize,synonym,
elasticsearch,Filter,Tokenize,Synonym,我们可以在elasticsearch中对原始字符串和同义词进行同等评分吗 例如,我创建了同义词文件: 私人 有限公司 我使用同义标记过滤器创建了一个索引。然后我索引了两个文档: curl -XPOST "http://localhost:9200/test1/test?pretty" -d '{ "entityName" : "ABC International Pvt Ltd"}' curl -XPOST "http://localhost:9200/test1/test?pret
curl -XPOST "http://localhost:9200/test1/test?pretty" -d
'{ "entityName" : "ABC International Pvt Ltd"}'
curl -XPOST "http://localhost:9200/test1/test?pretty" -d
'{ "entityName" : "ABC International Private Limited"}'
现在,当我搜索“ABC国际私人有限公司”时,第一个文档的得分为1.15,第二个文档的得分为0.57
有没有办法平等对待同义词
使用以下设置创建索引:
curl -XPUT 'localhost:9200/test1?pretty' -H 'Content-Type: application/json' -d'
{
"settings" : {
"index" : {
"analysis":{
"analyzer":{
"my_analyzer":{
"tokenizer":"standard",
"filter":["asciifolding", "standard", "lowercase", "my_metaphone", "synonym"]
}
},
"filter":{
"my_metaphone":{
"type":"phonetic",
"encoder":"metaphone",
"replace":false
},
"synonym" : {
"type" : "synonym",
"synonyms_path" : "synonyms.txt",
"ignore_case" : "true"
}
}
}
}
}
}'
创建索引时添加映射完成了此任务。如果没有映射,甚至没有应用同义词标记过滤器。下面是我用来创建索引的命令
curl -XPUT 'localhost:9200/test1?pretty' -H 'Content-Type: application/json' -d'
{
"settings" : {
"analysis":{
"filter":{
"my_metaphone":{
"type":"phonetic",
"encoder":"metaphone",
"replace":false
},
"synonym" : {
"type" : "synonym",
"synonyms_path" : "synonym.txt",
"ignore_case" : "true"
}
},
"analyzer":{
"my_analyzer":{
"type":"custom",
"tokenizer":"standard",
"filter":["asciifolding", "standard", "lowercase", "my_metaphone", "synonym"]
}
}
}
},
"mappings": {
"test": {
"properties": {
"text": {
"type": "text",
"analyzer": "my_analyzer",
"search_analyzer": "my_analyzer"
}
}
}
}
}'
你能展示一下你是如何定义你的索引的设置和映射的吗?你有可能有一个只有很少文档的多切分索引吗?如果是,请使用单个碎片索引重试。评分发生在碎片级别,所以如果没有很多文档,就会得到奇怪的结果。