Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
highlighting for scripted metric agg scripts
Browse files Browse the repository at this point in the history
Adding detection for [scripted metric aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-metrics-scripted-metric-aggregation.html)

```json
POST ledger/_search?size=0
{
    "query" : {
        "match_all" : {}
    },
    "aggs": {
        "profit": {
            "scripted_metric": {
                "init_script" : "params._agg.transactions = []",
                "map_script" : "params._agg.transactions.add(doc.type.value == 'sale' ? doc.amount.value : -1 * doc.amount.value)", 
                "combine_script" : "double profit = 0; for (t in params._agg.transactions) { profit += t } return profit",
                "reduce_script" : "double profit = 0; for (a in params._aggs) { profit += a } return profit"
            }
        }
    }
}
```
jpcarey authored and jbudz committed Mar 30, 2018
1 parent b3b2ff5 commit b3a569d
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ var jsonRules = function (root) {
rules[root] = [
{
token: ["variable", "whitespace", "ace.punctuation.colon", "whitespace", "punctuation.start_triple_quote"],
regex: '("script"|"inline")(\\s*?)(:)(\\s*?)(""")',
regex: '("script"|"inline"|"init_script"|"map_script"|"combine_script"|"reduce_script")(\\s*?)(:)(\\s*?)(""")',
next: "script-start",
merge: false,
push: true

0 comments on commit b3a569d

Please sign in to comment.