繁体   English   中英

ElasticSearch extended_bounds超出范围,没有数据/ hitdocs

[英]ElasticSearch extended_bounds over range with no data/hitdocs

我的范围不存在hitdocs。 当基于date_histogram聚合的查询在此无数据范围内使用extended_bounds运行时,不会返回任何内容。

但是,对于至少具有1个hitdoc的范围,将返回使用extended_bounds指定的范围的存储桶数据。

在没有hitdocs的情况下,如何在类似范围内获得类似的结果?

示例查询-

{
  "size": 0,
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "kind": "hit-search"
              }
            },
            {
              "range": {
                "startTime": {
                  "gte": 1506429661000,
                  "lte": 1506516061000
                }
              }
            }
          ]
        }
      }
    }
  },
  "aggs": {
    "perHost": {
      "terms": {
        "field": "user"
      },
      "aggs": {
        "ts": {
          "date_histogram": {
            "field": "startTime",
            "interval": "30m",
            "min_doc_count": 0,
            "extended_bounds": {
              "min": 1506429661000,
              "max": 1506516061000
            }
          },
          "aggs": {
            "numQuery": {
              "cardinality": {
                "field": "queryId"
              }
            }
          }
        }
      }
    }
  },
  "from": 0
}

可以将missing聚合用于同一对象。 上面的查询在更新后看起来像这样-

{
  "size": 0,
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "kind": "hit-search"
              }
            },
            {
              "range": {
                "startTime": {
                  "gte": 1506429661000,
                  "lte": 1506516061000
                }
              }
            }
          ]
        }
      }
    }
  },
  "aggs": {
    "perHost": {
      "missing": {
        "field": "user"
      },
      "aggs": {
        "ts": {
          "date_histogram": {
            "field": "startTime",
            "interval": "30m",
            "min_doc_count": 0,
            "extended_bounds": {
              "min": 1506429661000,
              "max": 1506516061000
            }
          },
          "aggs": {
            "numQuery": {
              "cardinality": {
                "field": "queryId"
              }
            }
          }
        }
      }
    }
  },
  "from": 0
}

观察extended_bounds似乎不能为missing工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM