Skip to content

[Upgraded] Support for multiple aggregations #3

@ftrudeau-pelcro

Description

@ftrudeau-pelcro

Hey there @pdphilip, thanks for this package.

Would it be possible to add support for multiple aggregations.

Using your package, the rawAggregation query below returns only one collection, yet there's actually 3 results: min_runtime, avg_runtime and max_runtime.

$body = [
            'size' => 0,
            'aggs' => [
                'min_runtime' => [
                    'min' => [
                        'field' => 'runtime',
                    ],
                ],
                'avg_runtime' => [
                    'avg' => [
                        'field' => 'runtime',
                    ],
                ],
                'max_runtime' => [
                    'max' => [
                        'field' => 'runtime',
                    ],
                ],
            ],
            'query' => [
                'bool' => [
                    'must' => [
                        'range' => [
                            'datetime' => [
                                'gte' => '2024-07-03',
                                'lte' => '2024-07-09',
                            ]
                        ]
                    ]
                ]
            ]
        ];
        $results = MyLog::rawAggregation($body);
        dump($results);
        exit;

Output of the DSL query from Dev Tools:

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 10000,
      "relation": "gte"
    },
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "avg_runtime": {
      "value": 1.1940759289359395
    },
    "min_runtime": {
      "value": 0.15059208869934082
    },
    "max_runtime": {
      "value": 66.78320789337158
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions