A
A
Anton Ivanov2018-12-04 16:38:18
elasticsearch
Anton Ivanov, 2018-12-04 16:38:18

How to get the number of documents excluded by the filter in elasticsearch?

Hello.
I make a selection with three nested aggregations: by application type, by date, by its version ..
Moreover, detailed data is needed only for the most used versions (they are known in advance)
A selection of this type:

{
  "size": 0,
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "must": [
              {
                "term": {
                  "app_type": "client"
                }
              },
              {
                "terms": {
                  "app_version": [
                    "32.1",
                    "32.2",
                    "32.3"
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "must": [
              {
                "term": {
                  "app_type": "server"
                }
              },
              {
                "terms": {
                  "app_version": [
                    "1",
                    "2",
                    "3"
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  },
  "aggs": {
    "apps": {
      "aggs": {
        "days": {
          "aggs": {
            "app_versions": {
              "terms": {
                "field": "app_version"
              }
            }
          },
          "terms": {
            "field": "day",
            "order": {
              "_key": "desc"
            }
          }
        }
      },
      "terms": {
        "field": "app_type"
      }
    }
  }
}

The question is how to get the number of documents for versions that were excluded by the filter. This is the "sum_other_doc_count" field, as I understand it.
Thanks

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question