Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metric aggregation fails in composite aggregation #28688

Closed
freedrikp opened this issue Feb 15, 2018 · 1 comment
Closed

Metric aggregation fails in composite aggregation #28688

freedrikp opened this issue Feb 15, 2018 · 1 comment
Assignees

Comments

@freedrikp
Copy link

Hi!

I'm using Elasticsearch to store test results of a software. I'm running Elasticsearch on Docker CE with the following configuration:

Docker version 17.12.0-ce, build c97c6d6
Ubuntu 14.04.5 LTS 14.04 trusty
docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.1
docker.elastic.co/kibana/kibana-oss:6.2.1

The documents look like the following:

    {  
       "product":{  
          "software":{  
             "revision":"251ebc1ed721622f49c5485068f8b39c45005a20",
             "date":"2018-02-09T17:40:34+00:00"
          },
          "os":{  
             "name":"Ubuntu",
             "version":"14.04"
          }
       },
       "results":{  
          "summary":{  
             "Pass":2,
             "Fail":3
          }
       }
    }

I want to compute the average Pass and Fail numbers for all combinations of os.name and os.version for their newest software version, so I use the following Composite query:

    GET _search
    {
      "size": 0,
        "query": {
          "match_all": {}
        },
        "aggs": {
          "products": {
            "composite": {
              "sources": [
                {
                  "osName": {
                    "terms": {
                      "field": "product.os.name.keyword"
                    }
                  }
                },
                {
                  "osVer": {
                    "terms": {
                      "field": "product.os.version.keyword"
                    }
                  }
                }
              ]
            },
            "aggs": {
              "revision": {
                "terms": {
                  "field": "product.software.revision.keyword",
                  "order": {
                    "SWDate": "desc"
                  },
                  "size": 1
                },
                "aggs": {
                  "SWDate": {
                    "max": {
                      "field": "product.software.date"
                    }
                  },
                   "Pass": {
                    "avg": {
                      "field": "results.summary.Pass",
                      "missing": 0
                    }
                  }
                }
              }
            }
          }
        }
      }

However, this fails with:

    "_shards": {
        "total": 6,
        "successful": 1,
        "skipped": 0,
        "failed": 5,
        "failures": [
          {
            "shard": 0,
            "index": "test_results",
            "node": "<nodeId>",
            "reason": {
              "type": "illegal_state_exception",
              "reason": "Cannot replay yet, collection is not finished: postCollect() has not been called"
            }
          }
        ]
      }

If I remove the Pass average aggregation it does not fail but id does fail with other metric aggregations. Any ideas what I might do wrong? Thanks!

@jimczi jimczi self-assigned this Feb 16, 2018
jimczi added a commit to jimczi/elasticsearch that referenced this issue Feb 16, 2018
This change refactors the composite aggregator to handle deferrable sub-aggregators.
The previous implementation is not able to handle sub-aggregators that can defer the collection
(sub terms agg executed in `breadth_first` mode).

Closes elastic#28688
@colings86
Copy link
Contributor

@elastic/es-search-aggs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants