Wrong doc_count on Children Aggregation

request:

POST /test_tsdb_alias/_search?routing=ms_nginxgas3_count&track_total_hits=true
{
  "query": {
    "bool": {
      "filter": [
        {
          "has_parent": {
            "parent_type": "t",
            "query": {
              "bool": {
                "filter": [
                  {
                    "term": {
                      "metric": "ms_nginxgas3_count"
                    }
                  }
                ]
              }
            }
          }
        },
        {
          "range": {
            "ts": {
              "gte": "2019-10-30T13:00:00+0800",
              "lte": "2019-10-30T13:30:00+0800"
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "ff": {
      "aggs": {
        "to_p": {
          "parent": {
            "type": "p"
          },
          "aggs": {
            "tag": {
              "terms": {
                "field": "tag._type"
              },
              "aggs": {
                "to_c": {
                  "children": {
                    "type": "p"
                  }
                }
              }
            }
          }
        }
      },
      "filters": {
        "filters": {
          "ts": {
            "range": {
              "ts": {
                "gte": "2019-10-30T13:00:00+0800",
                "lte": "2019-10-30T13:30:00+0800"
              }
            }
          }
        }
      }
    }
  },
  "size": 0
}

response:

{
  "took" : 1048,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 64714,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "ff" : {
      "buckets" : {
        "ts" : {
          "doc_count" : 64714,
          "to_p" : {
            "doc_count" : 1714,
            "tag" : {
              "doc_count_error_upper_bound" : 0,
              "sum_other_doc_count" : 0,
              "buckets" : [
                {
                  "key" : "formal",
                  "doc_count" : 1624,
                  "to_c" : {
                    "doc_count" : 6568272
                  }
                },
                {
                  "key" : "test",
                  "doc_count" : 90,
                  "to_c" : {
                    "doc_count" : 52343
                  }
                }
              ]
            }
          }
        }
      }
    }
  }
}

=> The filter doesn't correspond to the children aggregation,
hits = 64714 vs agg doc_count = 6568272 + 52343.

Why? How to solve it?
Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.