1
在嵌套字段上運行匹配查詢時,是基於所有根文檔中的所有嵌套文檔計算的每個嵌套文檔的相關性分數,還是僅在單個根文檔下的嵌套文檔?基本上,當計算TF/IDF時,用於IDF的集合的範圍是什麼?如何在Elasticsearch中計算嵌套文檔相關性分數(TF/IDF)?
這裏是一個嵌套的文件:
PUT /channels_index
{
"mappings": {
"channel": {
"properties": {
"username": { "type": "string" },
"posts": {
"type": "nested",
"properties": {
"link": { "type": "string" },
"caption": { "type": "string" },
}
}
}
}
}
}
這裏是查詢:
GET channels/_search
{
"query": {
"nested": {
"path": "posts",
"query": {
"match": {
"posts.caption": "adidas"
}
},
"inner_hits": {}
}
}
}
然而,在我的結果,即使第二文檔具有內點擊率較高的最高分,第一個文檔的根分數在某種程度上更高。
{
"hits": {
"total": 2,
"max_score": 4.3327584,
"hits": [
{
"_index": "channels",
"_type": "channel",
"_id": "1",
"_score": 4.3327584,
"_source": {
"username": "user1",
"posts": [...]
},
"inner_hits": {
"posts": {
"hits": {
"total": 2,
"max_score": 5.5447335,
"hits": [...]
}
}
}
},
{
"_index": "channels",
"_type": "channel",
"_id": "2",
"_score": 4.2954993,
"_source": {
"username": "user2",
"posts": [...]
},
"inner_hits": {
"posts": {
"hits": {
"total": 13,
"max_score": 11.446381,
"hits": [...]
}
}
}
}
]
}
}
我不知道這個問題的答案在我頭頂,但它似乎像解釋參數可能能夠引導你到你的答案。您是否嘗試過在頂級查詢中轉換「explain」:true?這通常會給我類似問題的答案。 – Miek
謝謝,是的,我應該在我問這個問題之前就跑過了,馬上給了我答案。 – zachdb86
是的,這是一個非常有用的選項。很高興它的工作 – Miek