【发布时间】:2018-03-23 16:09:17
【问题描述】:
在嵌套字段上运行匹配查询时,每个嵌套文档的相关性分数是根据所有根文档中的所有嵌套文档计算的,还是仅基于单个根文档下的嵌套文档计算的?基本上计算TF/IDF的时候,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 ?这通常会给我类似问题的答案。
-
谢谢,是的,我应该在问问题之前运行它,立即给我答案。
-
是的,这是一个非常有用的选项。很高兴它成功了
标签: elasticsearch elasticsearch-5