Skip to content

SQL: add support for scripted metrics aggregations #37271

@astefan

Description

@astefan

SELECT MAX(IF(<condition>,<value1>,<value2>)) FROM test is not currently supported in ES-SQL, but such a query is possible in Elasticsearch through the use of scripts.
For example:

{
	"size":0,
    "aggs" : {
        "prices" : {
            "sum" : {
                "script" : {
                    "source": "if (doc['price'].size()>0) {if (doc.decider.value>0) return doc.price.value; else return 0;} else return 0;"
                }
            }
        }
    }
}

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