2
最近我們改變了Elasticsearch版本從2.4到5.4。彈性搜索更多喜歡這個查詢分數問題5.x
我們在版本5.x中發現了更像此查詢中的一個問題。
下面的查詢使用文本,找出類似文件
輸入查詢
POST /test/_search
{
"size": 10000,
"stored_fields": [
"docid"
],
"_source": false,
"query": {
"more_like_this": {
"fields": [
"textcontent"
],
"like": [
{
"_index": "test",
"_type": "object",
"_id": "AV0c9jvZXF-b5U5aNAWB"
}
],
"max_query_terms": 5000,
"min_term_freq": 1,
"min_doc_freq": 1
}
}
}
Elasticsearch 5.4 的Elasticsearch 2.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": 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"
]
}
}}
的輸出是在這兩個版本相同,除了文件的得分。 版本5.4給出的分數高於2.4。 我們依賴於我們工作的分數,所以如果分數改變,那麼對我們來說就是一個問題。請爲此提供解決方案?
你可以使用'explain'選擇與您的查詢,看看有什麼提供分數的差異設定爲所有指數? – Adonis
謝謝我得到的解決方案,它是內部算法bm25。 需要改變它的經典。 –
當然,如果可以的話,你可以寫一個答案來幫助你將焦點放在未解答的問題上嗎? – Adonis