elasticsearch 弹性搜索更像5.x中的查询分数问题
最近,我们将Elasticsearch的版本从2.4更改为5.4 我们在5.x版的类似查询中发现了一个问题 下面的查询用于按文本查找类似的文档 输入查询 Elasticsearch 2.4的输出 Elasticsearch 5.4的输出 { 两个版本的输出都相同,除了文档的分数。 5.4版的评分高于2.4版。elasticsearch 弹性搜索更像5.x中的查询分数问题,elasticsearch,lucene,nest,elasticsearch,Lucene,Nest,最近,我们将Elasticsearch的版本从2.4更改为5.4 我们在5.x版的类似查询中发现了一个问题 下面的查询用于按文本查找类似的文档 输入查询 Elasticsearch 2.4的输出 Elasticsearch 5.4的输出 { 两个版本的输出都相同,除了文档的分数。 5.4版的评分高于2.4版。 我们的工作依赖于分数,因此如果分数发生变化,这对我们来说是个问题。请提供解决方案?我得到了解决方案,在5.0版中,他们将默认相似性算法从经典更改为BM25,这就是原因。 创建索引时,只需将
我们的工作依赖于分数,因此如果分数发生变化,这对我们来说是个问题。请提供解决方案?我得到了解决方案,在5.0版中,他们将默认相似性算法从经典更改为BM25,这就是原因。 创建索引时,只需将相似性类型更改为经典。 及 若索引已经存在,那个么只需通过执行以下查询来更新所有索引的设置
PUT /_all/_settings?preserve_existing=true
{
"index.similarity.default.type": "classic"
}
你能在你的查询中使用
explain
选项来查看分数差异的原因吗?谢谢,我找到了解决方案,它是内部算法bm25。需要将其改为经典算法。当然没问题,如果可以,你能为你的问题写一个答案来帮助把注意力集中在未回答的问题上吗?
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 1.5381224,
"hits": [
{
"_index": "test",
"_type": "object",
"_id": "AVzjOOdilllQ-Gyal6Z9",
"_score": 1.5381224,
"fields": {
"docid": [
"2"
]
}
}, {
"_index": "test",
"_type": "object",
"_id": "AVzjOOdilllQ-Gyal63Z",
"_score": .5381224,
"fields": {
"docid": [
"3"
]
}
}, {
"_index": "test",
"_type": "object",
"_id": "AVzjOOdilllQ-Gyal6Z",
"_score": .381224,
"fields": {
"docid": [
"4"
]
}
}
"took": 16,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 1.5381224,
"hits": [
{
"_index": "test",
"_type": "object",
"_id": "AVzjOOdilllQ-Gyal6Z9",
"_score": 168.5381224,
"fields": {
"docid": [
"2"
]
}
}, {
"_index": "test",
"_type": "object",
"_id": "AVzjOOdilllQ-Gyal63Z",
"_score": 164.5381224,
"fields": {
"docid": [
"3"
]
}
}, {
"_index": "test",
"_type": "object",
"_id": "AVzjOOdilllQ-Gyal6Z",
"_score": 132.381224,
"fields": {
"docid": [
"4"
]
}
}}
PUT /_all/_settings?preserve_existing=true
{
"index.similarity.default.type": "classic"
}