- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我对 interval=week
和 min_doc_count=0
{
"aggs": {
"scores_by_date": {
"date_histogram": {
"field": "date",
"format": "yyyy-MM-dd",
"interval": "week",
"min_doc_count": 0
}
}
}
和日期过滤器从 Jan-01-2015
到 Feb-23-2015
{
"range": {
"document.date": {
"from": "2015-01-01",
"to": "2015-02-23"
}
}
}
我预计 Elasticsearch 会填满七个星期,即使是空的并返回桶,但最终只有一个项目在里面
{
"aggregations": {
"scores_by_date": {
"buckets": [
{
"key_as_string": "2015-01-05",
"key": 1420416000000,
"doc_count": 5
}
]
}
}
}
Elasticsearch 版本:1.4.0
我的聚合有什么问题,或者我如何使用 Elasticsearch 来填补缺失的周数?
最佳答案
您可以尝试指定扩展边界(在 histogram aggregations 的官方文档页面上有讨论此功能的文档)。这些文档中最相关的部分是:
With extended_bounds setting, you now can "force" the histogram aggregation to start building buckets on a specific min values and also keep on building buckets up to a max value (even if there are no documents anymore). Using extended_bounds only makes sense when min_doc_count is 0 (the empty buckets will never be returned if min_doc_count is greater than 0).
因此您的聚合可能必须看起来像这样以强制 ES 返回该范围内的空桶:
{
"aggs": {
"scores_by_date": {
"date_histogram": {
"field": "date",
"format": "yyyy-MM-dd",
"interval": "week",
"min_doc_count": 0,
"extended_bounds" : {
"min" : "2015-01-01",
"max" : "2015-02-23"
}
}
}
}
关于hadoop - Elasticsearch:数周的聚合 min_doc_count 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28675181/
我对 interval=week 和 min_doc_count=0 进行了以下聚合 { "aggs": { "scores_by_date": { "date_histogr
我是一名优秀的程序员,十分优秀!