The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

App::ElasticSearch::Utilities::Aggregations - Code to simplify creating and working with Elasticsearh aggregations

VERSION

version 7.9.1

FUNCTIONS

is_single_stat()

Returns true if an aggregation returns a single value.

expand_aggregate_string( token )

Takes a simplified aggregation grammar and expands it the full aggregation hash.

Simple Terms:

field_name

To

{
    field_name => {
        terms => {
            field => 'field_name',
            size  => 20,
        }
    }
}

Alias expansion:

alias=field_name

To

{
    alias => {
        terms => {
            field => 'field_name',
            size  => 20,
        }
    }
}

Parameters:

alias=field_name:10

To

{
    alias => {
        terms => {
            field => 'field_name',
            size  => 10,
        }
    }
}

Parameters, k/v:

alias=field_name:size=13

To

{
    alias => {
        terms => {
            field => 'field_name',
            size  => 13,
        }
    }
}

es_flatten_aggregations()

Takes the aggregations section of the query result and parses it into a flat structure so each row contains all the sub aggregation information.

It returns an array reference, containing arrray references. The individual rows of the array are ordered in a depth first fashion. The array does include a key for every value, so the array can be cast to a hash safely.

AUTHOR

Brad Lhotsky <brad@divisionbyzero.net>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2021 by Brad Lhotsky.

This is free software, licensed under:

The (three-clause) BSD License