Skip to content

Commit

Permalink
[es] scripts.inline -> scripts.source (#30457) (#32701)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz authored Mar 8, 2019
1 parent 32a9f42 commit 10a2ef3
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-es-query/src/filters/__tests__/phrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions packages/kbn-es-query/src/filters/__tests__/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
});

Expand All @@ -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);
Expand Down Expand Up @@ -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`);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-query/src/filters/phrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function getPhraseScript(field, value) {

return {
script: {
inline: script,
source: script,
lang: field.lang,
params: {
value: convertedValue
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-query/src/filters/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function getRangeScript(field, params) {

return {
script: {
inline: script,
source: script,
params: knownParams,
lang: field.lang
}
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/console/api_server/es_6_0/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ describe('Input Tokenization', () => {
['start', 'json', 'json', 'start'],
'POST _search\n' +
'{\n' +
' "script": { "inline": "" }\n' +
' "script": { "source": "" }\n' +
'}'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
Scripts in requests
-------------------------------------
{
"f": { "script" : { "inline": "test\ntest\\2" } },
"f": { "script" : { "source": "test\ntest\\2" } },
"g": { "script" : "second + \"\\\";" },
"f": "short with \\",
"h": 1,
"script": "a + 2"
}
-------------------------------------
{
"f": { "script" : { "inline": """
"f": { "script" : { "source": """
test
test\2
""" } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const minMaxAgg = (field) => {
const aggBody = {};
if (field.scripted) {
aggBody.script = {
inline: field.script,
source: field.script,
lang: field.lang
};
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function buildAggBody(fieldName, scriptedFields) {
if (scriptedField) {
return {
script: {
inline: scriptedField.script,
source: scriptedField.script,
lang: scriptedField.lang
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_types/metrics/top_hit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -203,7 +203,7 @@ export const topHitMetricAgg = new MetricAggType({
{
_script: {
script: {
inline: sortField.script,
source: sortField.script,
lang: sortField.lang
},
type: sortField.type,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/param_types/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('SearchSource#normalizeSortRequest', function () {
normalizedSort = {
_script: {
script: {
inline: indexField.script,
source: indexField.script,
lang: indexField.lang
},
type: indexField.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/index_patterns/_get_computed_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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
Expand All @@ -92,7 +92,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
Expand All @@ -102,19 +102,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)'
}
}
}
Expand Down Expand Up @@ -155,7 +155,7 @@ export const watch = {
score: {
script: {
lang: 'painless',
inline: 'Math.round(doc["influencer_score"].value)'
source: 'Math.round(doc["influencer_score"].value)'
}
}
}
Expand Down Expand Up @@ -199,7 +199,7 @@ export const watch = {
score: {
script: {
lang: 'painless',
inline: 'Math.round(doc["record_score"].value)'
source: 'Math.round(doc["record_score"].value)'
}
}
}
Expand Down

0 comments on commit 10a2ef3

Please sign in to comment.