From 9754b6c94bc655e1f71c7764ca079266332db4f6 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Fri, 30 Mar 2018 14:13:20 -0500 Subject: [PATCH] [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 --- .../public/src/sense_editor/mode/x_json_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js b/src/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js index 4b1d0e3d1c06a..bddca4f688784 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js @@ -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