我在以前的帖子中找不到答案,所以我希望我的帖子是相关的。我遇到了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过滤器的字段(或者它实际上应该被调用的任何内容)被设置为“”:
properties: {
type_ref2Strack: {
properties: {
position: {
type: long
}
name: {
index: not_analyzed
norms: {
enabled: false
}
index_options: docs
type: string
}
}
}
}发布于 2014-07-31 03:27:50
这是众所周知的对elasticsearch方面(现在称为聚合)的长期限制。
关键的问题是,它对给定大小的每个碎片运行面,然后组合结果,这意味着计数可以被砍掉。
有两种非理想的方法来处理这个问题:
有关更多信息,请参见此处:
approximate
https://stackoverflow.com/questions/25039579
复制相似问题