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

MultiValuesSource Aggregations (including weighted_avg) ignore format #54365

Closed
imotov opened this issue Mar 27, 2020 · 1 comment · Fixed by #54366
Closed

MultiValuesSource Aggregations (including weighted_avg) ignore format #54365

imotov opened this issue Mar 27, 2020 · 1 comment · Fixed by #54366

Comments

@imotov
Copy link
Contributor

imotov commented Mar 27, 2020

To reproduce:

DELETE test

POST test/_bulk
{"index":{}}
{"foo":[15.2, 13], "bar":15.9}
{"index":{}}
{"foo":15.3, "bar":15.9}

POST test/_search
{
  "size": 0,
  "aggs": {
    "a": {
      "avg": {
        "field":"foo",
        "format": "000000.0%"
      }
    },
    "wa": {
      "weighted_avg": {
        "value": {"field":"foo"},
        "weight": {"field":"bar"},
        "format": "000000.0%"
      }
    }
  }
}

response:

{
   .... 
  "aggregations" : {
    "a" : {
      "value" : 14.5,
      "value_as_string" : "001450.0%"
    },
    "wa" : {
      "value" : 14.5
    }
  }
}

It looks like the problem is caused by MultiValuesSourceAggregationBuilder.resolveFormat method that always returns RAW format.

Since the response type in the weighted_avg aggregation is always double and doesn't depend on the types of input value sources, we might need to address #47469 before addressing this issue.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (:Analytics/Aggregations)

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

Successfully merging a pull request may close this issue.

2 participants