我在以前的帖子中找不到答案,所以我希望我的帖子是相关的。 我在使用ElasticSearch术语方面遇到了麻烦。
当我查询每个术语方面的文档数时,我得到,对于某些字段值我们说8,但是当我查询具有该字段的特定值的文档计数时,我得到,比方说19。
为了更加深思熟虑,我正在使用Kibana,这里是查询和回复(我被告知要重命名字段值fyi):
所有术语构面计数查询:
{
"facets" : {
"terms" : {
"terms" : {
**"fields" : ["field.name"],**
"size" : 6,
"order" : "count",
"exclude" : []
},
"facet_filter" : {
"fquery" : {
"query" : {
"filtered" : {
"query" : {
"bool" : {
"should" : [{
"query_string" : {
"query" : "*"
}
}
]
}
},
"filter" : {
"bool" : {
"must" : [{
"match_all" : {}
}
]
}
}
}
}
}
}
}
},
"size" : 0
}
回复:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 20374,
"max_score" : 0.0,
"hits" : []
},
"facets" : {
"terms" : {
"_type" : "terms",
"missing" : 10567,
"total" : 9918,
"other" : 9781,
"terms" : [{
"term" : "fieldValue1"
"count" : 43
}, {
"term" : "fieldValue2",
"count" : 27
}, {
"term" : "fieldValue3",
"count" : 23
}, {
"term" : "fieldValue4",
"count" : 23
}, {
"term" : "fieldValue5",
"count" : 13
}, {
"term" : "fieldValue6",
"count" : 8
}
]
}
}
}
查询“fieldValue6”
{
"facets" : {
"terms" : {
"terms" : {
"fields" : ["field.name"],
"size" : 6,
"order" : "count",
"exclude" : []
},
"facet_filter" : {
"fquery" : {
"query" : {
"filtered" : {
"query" : {
"bool" : {
"should" : [{
"query_string" : {
"query" : "*"
}
}
]
}
},
"filter" : {
"bool" : {
"must" : [{
"terms" : {
"field.name" : ["fieldValue6"]
}
}
]
}
}
}
}
}
}
}
},
"size"
回复:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 20374,
"max_score" : 0.0,
"hits" : []
},
"facets" : {
"terms" : {
"_type" : "terms",
"missing" : 0,
"total" : 19,
"other" : 0,
"terms" : [{
"term" : "fieldValue6",
"count" : 19
}
]
}
}
}
我应用facet过滤器(或实际应该调用的任何东西)的字段设置为“not analyze”:
properties: {
type_ref2Strack: {
properties: {
position: {
type: long
}
name: {
index: not_analyzed
norms: {
enabled: false
}
index_options: docs
type: string
}
}
}
}
答案 0 :(得分:0)
这是弹性研究方面(现在称为聚合)的长期已知限制。
关键问题在于它针对每个具有给定大小的分片运行构面,然后将结果组合在一起,这意味着计数可以被切断。
有两种非理想的方法可以解决这个问题:
有关详细信息,请参阅此处: