Kibana Query How to Drop Partial Buckets?

Hi,

I get the below three buckets typically in my query result when I run my query. Is it possible to drop the partial buckets? Lets assume I get 3 buckets (B1, B2, B3). I just want to view results of B2 (please see required result below)in my query result and drop B1 and B3 for example.

Actual Result

      "buckets" : [
        {
          "key_as_string" : "2020-06-03T14:15:00.000Z",
          "key" : 1591193700000,
          "doc_count" : 78139554,
          "cmtsId_list" : {
            "doc_count_error_upper_bound" : 126180,
            "sum_other_doc_count" : 78097327,
            "buckets" : [
              {
                "key" : "b5cb9b4fe8be1663eb3bc593b2ad21e6afe29448",
                "doc_count" : 42227
              }
            ]
          },
          "numberof_cmtsId" : {
            "value" : 4022
          }
        },
        {
          "key_as_string" : "2020-06-03T15:00:00.000Z",
          "key" : 1591196400000,
          "doc_count" : 447759475,
          "cmtsId_list" : {
            "doc_count_error_upper_bound" : 530945,
            "sum_other_doc_count" : 447259815,
            "buckets" : [
              {
                "key" : "eaca9ef3c7ed39402a7101b1ab1443338d0607de",
                "doc_count" : 499660
              }
            ]
          },
          "numberof_cmtsId" : {
            "value" : 4133
          }
        },
        {
          "key_as_string" : "2020-06-03T15:45:00.000Z",
          "key" : 1591199100000,
          "doc_count" : 82735016,
          "cmtsId_list" : {
            "doc_count_error_upper_bound" : 115872,
            "sum_other_doc_count" : 82664949,
            "buckets" : [
              {
                "key" : "91259535611a418126767957fa70c13339ca7b91",
                "doc_count" : 70067
              }
            ]
          },
          "numberof_cmtsId" : {
            "value" : 4054
          }
      }
]

Required Result

{
          "key_as_string" : "2020-06-03T15:00:00.000Z",
          "key" : 1591196400000,
          "doc_count" : 447759475,
          "cmtsId_list" : {
            "doc_count_error_upper_bound" : 530945,
            "sum_other_doc_count" : 447259815,
            "buckets" : [
              {
                "key" : "eaca9ef3c7ed39402a7101b1ab1443338d0607de",
                "doc_count" : 499660
              }
            ]
          },
          "numberof_cmtsId" : {
            "value" : 4133
          }
        },

Can someone let me know if thats possible ? Please and thank you :slight_smile:

What aggregation are you using for x-axis? The date histogram aggregation has a check box to drop partial buckets

Hi Nathan,

I am using the date histogram aggregation. Below is my query. However I am not sure how to implement drop partial bucket in kibana query? Sorry I am new to this. Can you please help?

{
  "query": {
    "range": {
      "timestamp": {
        "gte": "now-90m/m",
        "lte": "now-30m/m"
      }
    }
  },
  "size": 0,
  "aggs": {
    "every45min_list": {
      "date_histogram": {
        "field": "timestamp",
        "fixed_interval": "45m"
      },
      "aggs": {
        "Id_list": {
          "terms": {
            "field": "cmtsId",
            "size": 1
          }
        },
        "numberof_Id": {
          "cardinality": {
            "field": "cmtsId"
          }
        }
      }
    }
  }
}

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