From dc717685bfb62283d321d9a16021024ab1f3fc21 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Thu, 7 Feb 2019 18:18:20 -0600 Subject: [PATCH] [es] scripts.inline -> scripts.source --- .../kbn-es-query/src/filters/__tests__/phrase.js | 2 +- .../kbn-es-query/src/filters/__tests__/range.js | 8 ++++---- packages/kbn-es-query/src/filters/phrase.js | 2 +- packages/kbn-es-query/src/filters/range.js | 2 +- .../console/api_server/es_6_0/globals.js | 4 ++-- .../console/api_server/es_6_0/search.js | 2 +- .../public/tests/src/input_tokenization.test.js | 2 +- .../public/tests/src/utils_string_expanding.txt | 4 ++-- .../public/control/list_control_factory.js | 2 +- .../public/control/range_control_factory.js | 2 +- .../server/series_functions/__tests__/es.js | 6 +++--- .../server/series_functions/es/lib/agg_body.js | 2 +- .../series_functions/es/lib/create_date_agg.js | 2 +- src/ui/public/agg_types/buckets/histogram.js | 2 +- src/ui/public/agg_types/metrics/top_hit.js | 4 ++-- src/ui/public/agg_types/param_types/field.js | 2 +- .../__tests__/normalize_sort_request.js | 2 +- .../search_source/_normalize_sort_request.js | 2 +- .../public/index_patterns/_get_computed_fields.js | 2 +- .../new_job/simple/components/watcher/watch.js | 14 +++++++------- 20 files changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/kbn-es-query/src/filters/__tests__/phrase.js b/packages/kbn-es-query/src/filters/__tests__/phrase.js index 64d0bcc3ce275..0fd2a5fbd0760 100644 --- a/packages/kbn-es-query/src/filters/__tests__/phrase.js +++ b/packages/kbn-es-query/src/filters/__tests__/phrase.js @@ -53,7 +53,7 @@ describe('Filter Manager', function () { const field = getField(indexPattern, 'script number'); expected.meta.field = 'script number'; _.set(expected, 'script.script', { - inline: '(' + field.script + ') == value', + source: '(' + field.script + ') == value', lang: 'expression', params: { value: 5, diff --git a/packages/kbn-es-query/src/filters/__tests__/range.js b/packages/kbn-es-query/src/filters/__tests__/range.js index 9b022bfe4617a..6fe914475836f 100644 --- a/packages/kbn-es-query/src/filters/__tests__/range.js +++ b/packages/kbn-es-query/src/filters/__tests__/range.js @@ -51,7 +51,7 @@ describe('Filter Manager', function () { expected.meta.field = 'script number'; _.set(expected, 'script.script', { lang: 'expression', - inline: '(' + field.script + ')>=gte && (' + field.script + ')<=lte', + source: '(' + field.script + ')>=gte && (' + field.script + ')<=lte', params: { value: '>=1 <=3', gte: 1, @@ -68,7 +68,7 @@ describe('Filter Manager', function () { `gte(() -> { ${field.script} }, params.gte) && ` + `lte(() -> { ${field.script} }, params.lte)`; - const inlineScript = buildRangeFilter(field, { gte: 1, lte: 3 }, indexPattern).script.script.inline; + const inlineScript = buildRangeFilter(field, { gte: 1, lte: 3 }, indexPattern).script.script.source; expect(inlineScript).to.be(expected); }); @@ -89,7 +89,7 @@ describe('Filter Manager', function () { params[key] = 5; const filter = buildRangeFilter(field, params, indexPattern); - expect(filter.script.script.inline).to.be( + expect(filter.script.script.source).to.be( '(' + field.script + ')' + operator + key); expect(filter.script.script.params[key]).to.be(5); expect(filter.script.script.params.value).to.be(operator + 5); @@ -120,7 +120,7 @@ describe('Filter Manager', function () { it('does not contain a script condition for the infinite side', function () { const field = getField(indexPattern, 'script number'); const script = field.script; - expect(filter.script.script.inline).to.equal(`(${script})>=gte`); + expect(filter.script.script.source).to.equal(`(${script})>=gte`); }); }); }); diff --git a/packages/kbn-es-query/src/filters/phrase.js b/packages/kbn-es-query/src/filters/phrase.js index b71724ab60d76..032ad9d84c1fa 100644 --- a/packages/kbn-es-query/src/filters/phrase.js +++ b/packages/kbn-es-query/src/filters/phrase.js @@ -41,7 +41,7 @@ export function getPhraseScript(field, value) { return { script: { - inline: script, + source: script, lang: field.lang, params: { value: convertedValue diff --git a/packages/kbn-es-query/src/filters/range.js b/packages/kbn-es-query/src/filters/range.js index 88be09c997154..218a112a1610b 100644 --- a/packages/kbn-es-query/src/filters/range.js +++ b/packages/kbn-es-query/src/filters/range.js @@ -98,7 +98,7 @@ export function getRangeScript(field, params) { return { script: { - inline: script, + source: script, params: knownParams, lang: field.lang } diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/globals.js b/src/legacy/core_plugins/console/api_server/es_6_0/globals.js index 513adbe0fe2fc..1a2e9f585f35c 100644 --- a/src/legacy/core_plugins/console/api_server/es_6_0/globals.js +++ b/src/legacy/core_plugins/console/api_server/es_6_0/globals.js @@ -62,9 +62,9 @@ export default function (api) { api.addGlobalAutocompleteRules('script', { __template: { - inline: 'SCRIPT' + source: 'SCRIPT' }, - inline: 'SCRIPT', + source: 'SCRIPT', file: 'FILE_SCRIPT_NAME', id: 'SCRIPT_ID', lang: '', diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/search.js b/src/legacy/core_plugins/console/api_server/es_6_0/search.js index 646d299b4c1a6..f77144b1524c6 100644 --- a/src/legacy/core_plugins/console/api_server/es_6_0/search.js +++ b/src/legacy/core_plugins/console/api_server/es_6_0/search.js @@ -207,7 +207,7 @@ export default function (api) { api.addEndpointDescription('render_search_template', { data_autocomplete_rules: { __one_of: [ - { inline: { __scope_link: 'search' } }, + { source: { __scope_link: 'search' } }, { __scope_link: 'GLOBAL.script' }, ], params: {}, diff --git a/src/legacy/core_plugins/console/public/tests/src/input_tokenization.test.js b/src/legacy/core_plugins/console/public/tests/src/input_tokenization.test.js index 914bd4854e8c4..3c249a0c86bc5 100644 --- a/src/legacy/core_plugins/console/public/tests/src/input_tokenization.test.js +++ b/src/legacy/core_plugins/console/public/tests/src/input_tokenization.test.js @@ -322,7 +322,7 @@ describe('Input Tokenization', () => { ['start', 'json', 'json', 'start'], 'POST _search\n' + '{\n' + - ' "script": { "inline": "" }\n' + + ' "script": { "source": "" }\n' + '}' ); diff --git a/src/legacy/core_plugins/console/public/tests/src/utils_string_expanding.txt b/src/legacy/core_plugins/console/public/tests/src/utils_string_expanding.txt index 3a468e65ddbf5..762e0ad164634 100644 --- a/src/legacy/core_plugins/console/public/tests/src/utils_string_expanding.txt +++ b/src/legacy/core_plugins/console/public/tests/src/utils_string_expanding.txt @@ -2,7 +2,7 @@ Scripts in requests ------------------------------------- { - "f": { "script" : { "inline": "test\ntest\\2" } }, + "f": { "script" : { "source": "test\ntest\\2" } }, "g": { "script" : "second + \"\\\";" }, "f": "short with \\", "h": 1, @@ -10,7 +10,7 @@ Scripts in requests } ------------------------------------- { - "f": { "script" : { "inline": """ + "f": { "script" : { "source": """ test test\2 """ } }, diff --git a/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.js b/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.js index b15448f9b22df..e1817d2d81a84 100644 --- a/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.js +++ b/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.js @@ -45,7 +45,7 @@ const termsAgg = ({ field, size, direction, query }) => { if (field.scripted) { terms.script = { - inline: field.script, + source: field.script, lang: field.lang }; terms.valueType = field.type === 'number' ? 'float' : field.type; diff --git a/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.js b/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.js index 7e24bc883b167..78a0e42771c2b 100644 --- a/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.js +++ b/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.js @@ -31,7 +31,7 @@ const minMaxAgg = (field) => { const aggBody = {}; if (field.scripted) { aggBody.script = { - inline: field.script, + source: field.script, lang: field.lang }; } else { diff --git a/src/legacy/core_plugins/timelion/server/series_functions/__tests__/es.js b/src/legacy/core_plugins/timelion/server/series_functions/__tests__/es.js index 693df0206b31c..cbeac18e3542f 100644 --- a/src/legacy/core_plugins/timelion/server/series_functions/__tests__/es.js +++ b/src/legacy/core_plugins/timelion/server/series_functions/__tests__/es.js @@ -143,7 +143,7 @@ describe(filename, () => { expect(agg.time_buckets.aggs['avg(scriptedBytes)']).to.eql({ avg: { script: { - inline: 'doc["bytes"].value', + source: 'doc["bytes"].value', lang: 'painless' } } @@ -338,14 +338,14 @@ describe(filename, () => { expect(aggs.scriptedBeer.meta.type).to.eql('split'); expect(aggs.scriptedBeer.terms.script).to.eql({ - inline: 'doc["beer"].value', + source: 'doc["beer"].value', lang: 'painless' }); expect(aggs.scriptedBeer.terms.size).to.eql(5); expect(aggs.scriptedBeer.aggs.scriptedWine.meta.type).to.eql('split'); expect(aggs.scriptedBeer.aggs.scriptedWine.terms.script).to.eql({ - inline: 'doc["wine"].value', + source: 'doc["wine"].value', lang: 'painless' }); expect(aggs.scriptedBeer.aggs.scriptedWine.terms.size).to.eql(10); diff --git a/src/legacy/core_plugins/timelion/server/series_functions/es/lib/agg_body.js b/src/legacy/core_plugins/timelion/server/series_functions/es/lib/agg_body.js index 5db5e44426ac8..331337a1ed491 100644 --- a/src/legacy/core_plugins/timelion/server/series_functions/es/lib/agg_body.js +++ b/src/legacy/core_plugins/timelion/server/series_functions/es/lib/agg_body.js @@ -27,7 +27,7 @@ export function buildAggBody(fieldName, scriptedFields) { if (scriptedField) { return { script: { - inline: scriptedField.script, + source: scriptedField.script, lang: scriptedField.lang } }; diff --git a/src/legacy/core_plugins/timelion/server/series_functions/es/lib/create_date_agg.js b/src/legacy/core_plugins/timelion/server/series_functions/es/lib/create_date_agg.js index 6ea1e64fe93bd..9a5c5dd4e9595 100644 --- a/src/legacy/core_plugins/timelion/server/series_functions/es/lib/create_date_agg.js +++ b/src/legacy/core_plugins/timelion/server/series_functions/es/lib/create_date_agg.js @@ -46,7 +46,7 @@ export default function createDateAgg(config, tlConfig, scriptedFields) { dateAgg.time_buckets.aggs[metric] = { bucket_script: { buckets_path: '_count', - script: { inline: '_value', lang: 'expression' } + script: { source: '_value', lang: 'expression' } } }; } else if (metric[0] && metric[1]) { diff --git a/src/ui/public/agg_types/buckets/histogram.js b/src/ui/public/agg_types/buckets/histogram.js index aac100b5bffdc..18dcce1ae4ac2 100644 --- a/src/ui/public/agg_types/buckets/histogram.js +++ b/src/ui/public/agg_types/buckets/histogram.js @@ -79,7 +79,7 @@ export const histogramBucketAgg = new BucketAggType({ modifyAggConfigOnSearchRequestStart(aggConfig, searchSource) { const field = aggConfig.getField(); const aggBody = field.scripted - ? { script: { inline: field.script, lang: field.lang } } + ? { script: { source: field.script, lang: field.lang } } : { field: field.name }; return searchSource diff --git a/src/ui/public/agg_types/metrics/top_hit.js b/src/ui/public/agg_types/metrics/top_hit.js index 8803b7a6e84c5..ad520cfc58c02 100644 --- a/src/ui/public/agg_types/metrics/top_hit.js +++ b/src/ui/public/agg_types/metrics/top_hit.js @@ -75,7 +75,7 @@ export const topHitMetricAgg = new MetricAggType({ output.params.script_fields = { [ field.name ]: { script: { - inline: field.script, + source: field.script, lang: field.lang } } @@ -203,7 +203,7 @@ export const topHitMetricAgg = new MetricAggType({ { _script: { script: { - inline: sortField.script, + source: sortField.script, lang: sortField.lang }, type: sortField.type, diff --git a/src/ui/public/agg_types/param_types/field.js b/src/ui/public/agg_types/param_types/field.js index 38eaa75d43ec9..025d78e211d98 100644 --- a/src/ui/public/agg_types/param_types/field.js +++ b/src/ui/public/agg_types/param_types/field.js @@ -132,7 +132,7 @@ FieldParamType.prototype.write = function (aggConfig, output) { if (field.scripted) { output.params.script = { - inline: field.script, + source: field.script, lang: field.lang, }; } else { diff --git a/src/ui/public/courier/search_source/__tests__/normalize_sort_request.js b/src/ui/public/courier/search_source/__tests__/normalize_sort_request.js index 7904fec79b84e..810f9cf045495 100644 --- a/src/ui/public/courier/search_source/__tests__/normalize_sort_request.js +++ b/src/ui/public/courier/search_source/__tests__/normalize_sort_request.js @@ -78,7 +78,7 @@ describe('SearchSource#normalizeSortRequest', function () { normalizedSort = { _script: { script: { - inline: indexField.script, + source: indexField.script, lang: indexField.lang }, type: indexField.type, diff --git a/src/ui/public/courier/search_source/_normalize_sort_request.js b/src/ui/public/courier/search_source/_normalize_sort_request.js index aef37de2d11f5..d5943771f83b8 100644 --- a/src/ui/public/courier/search_source/_normalize_sort_request.js +++ b/src/ui/public/courier/search_source/_normalize_sort_request.js @@ -52,7 +52,7 @@ export function NormalizeSortRequestProvider(config) { sortField = '_script'; sortValue = { script: { - inline: indexField.script, + source: indexField.script, lang: indexField.lang }, type: castSortType(indexField.type), diff --git a/src/ui/public/index_patterns/_get_computed_fields.js b/src/ui/public/index_patterns/_get_computed_fields.js index 422165b890324..62fa7cbe0b625 100644 --- a/src/ui/public/index_patterns/_get_computed_fields.js +++ b/src/ui/public/index_patterns/_get_computed_fields.js @@ -38,7 +38,7 @@ export function getComputedFields() { _.each(self.getScriptedFields(), function (field) { scriptFields[field.name] = { script: { - inline: field.script, + source: field.script, lang: field.lang } }; diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/components/watcher/watch.js b/x-pack/plugins/ml/public/jobs/new_job/simple/components/watcher/watch.js index aab27151036ff..26b9710fbd4ad 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/components/watcher/watch.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/components/watcher/watch.js @@ -81,7 +81,7 @@ export const watch = { start: { script: { lang: 'painless', - inline: `LocalDateTime.ofEpochSecond((doc["timestamp"].date.getMillis()-((doc["bucket_span"].value * 1000) + source: `LocalDateTime.ofEpochSecond((doc["timestamp"].date.getMillis()-((doc["bucket_span"].value * 1000) * params.padding)) / 1000, 0, ZoneOffset.UTC).toString()+\":00.000Z\"`, params: { 'padding': 10 @@ -91,7 +91,7 @@ export const watch = { end: { script: { lang: 'painless', - inline: `LocalDateTime.ofEpochSecond((doc["timestamp"].date.getMillis()+((doc["bucket_span"].value * 1000) + source: `LocalDateTime.ofEpochSecond((doc["timestamp"].date.getMillis()+((doc["bucket_span"].value * 1000) * params.padding)) / 1000, 0, ZoneOffset.UTC).toString()+\":00.000Z\"`, params: { 'padding': 10 @@ -101,19 +101,19 @@ export const watch = { timestamp_epoch: { script: { lang: 'painless', - inline: 'doc["timestamp"].date.getMillis()/1000' + source: 'doc["timestamp"].date.getMillis()/1000' } }, timestamp_iso8601: { script: { lang: 'painless', - inline: 'doc["timestamp"].date' + source: 'doc["timestamp"].date' } }, score: { script: { lang: 'painless', - inline: 'Math.round(doc["anomaly_score"].value)' + source: 'Math.round(doc["anomaly_score"].value)' } } } @@ -154,7 +154,7 @@ export const watch = { score: { script: { lang: 'painless', - inline: 'Math.round(doc["influencer_score"].value)' + source: 'Math.round(doc["influencer_score"].value)' } } } @@ -198,7 +198,7 @@ export const watch = { score: { script: { lang: 'painless', - inline: 'Math.round(doc["record_score"].value)' + source: 'Math.round(doc["record_score"].value)' } } }