Skip to content

MultiValuesSource Aggregations (including weighted_avg) ignore format #54365

@imotov

Description

@imotov

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions