[console] highlighting for scripted metric agg scripts (#15377)

* highlighting for scripted metric agg scripts

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"
            }
        }
    }
}
```

* Update x_json_highlight_rules.js

* [console] Remove capture group from *_script check

* allow source
This commit is contained in:
Jonathan Budzenski 2018-03-30 14:13:20 -05:00 committed by Jonathan Budzenski
parent bbfd72b8cd
commit af49683bed
No known key found for this signature in database
GPG key ID: D28BF9418FA0F292

View file

@ -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"|"source")(\\s*?)(:)(\\s*?)(""")',
next: "script-start",
merge: false,
push: true