Comparison of two aggregation results

Hi everyone!

I'm new to elastic. The question arises, how can I compare two aggregation results and output the number of matches and differences.

{
  "size": 0, 
  "aggs": {
    "list_ids_in_current_range": {
      "range": {
        "field": "time_start",
        "ranges": [
          {
            "from": 1634342400000,
            "to": 1637107200000
          }
        ]
      },
      "aggs": {
        "ids": {
          "terms": {
            "field": "id.keyword",
            "size": 2147483647
          }
        }
      }
    },
    "list_existed_ids":{
      "range": {
        "field": "time_start",
        "ranges": [
          {
            "to": 1634342400000
          }
        ]
      },
      "aggs": {
        "ids": {
          "terms": {
            "field": "id.keyword",
            "size": 2147483647
          }
        }
      }
    }
  }
}

I have tried to aggregate using such aggregation, but it is not suitable for my case:

{"size": 0, 
  "aggs":
  {
    "ids_per_day": {
      "date_histogram": {
        "field": "time_start",
        "fixed_interval": "1d"
      },
      "aggs": {
        "distinct": {
          "cardinality": {
            "field": "id.keyword"
          }
        },
        "total_new": {
          "cumulative_cardinality": {
            "buckets_path": "distinct"
          }
        },
        "incremental_new": {
          "derivative": {
            "buckets_path": "total_new"
          }
        }
      }
    }
  }
}

This aggregation will be built into the custom visualization on VEGA.

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