From f32eb2636fbbf0d0bacc8c775744cb9e2fe6dc09 Mon Sep 17 00:00:00 2001 From: chenryn Date: Sat, 14 May 2016 23:32:30 +0800 Subject: [PATCH 1/4] add scripting language selection --- .../sections/indices/_scripted_fields.js | 2 ++ src/ui/public/field_editor/field_editor.html | 16 ++++++++++++++++ src/ui/public/field_editor/field_editor.js | 15 ++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/core_plugins/kibana/public/management/sections/indices/_scripted_fields.js b/src/core_plugins/kibana/public/management/sections/indices/_scripted_fields.js index e4a00ad8540b6..094d2cb23c633 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/_scripted_fields.js +++ b/src/core_plugins/kibana/public/management/sections/indices/_scripted_fields.js @@ -25,6 +25,7 @@ uiModules.get('apps/management') $scope.perPage = 25; $scope.columns = [ { title: 'name' }, + { title: 'lang' }, { title: 'script' }, { title: 'format' }, { title: 'controls', sortable: false } @@ -46,6 +47,7 @@ uiModules.get('apps/management') return [ _.escape(field.name), + _.escape(field.lang), _.escape(field.script), _.get($scope.indexPattern, ['fieldFormatMap', field.name, 'type', 'title']), { diff --git a/src/ui/public/field_editor/field_editor.html b/src/ui/public/field_editor/field_editor.html index 18e065a6b7b6d..177cae7e400f0 100644 --- a/src/ui/public/field_editor/field_editor.html +++ b/src/ui/public/field_editor/field_editor.html @@ -19,7 +19,14 @@
+ @@ -83,6 +90,15 @@

+
+ + +
+
diff --git a/src/ui/public/field_editor/field_editor.js b/src/ui/public/field_editor/field_editor.js index 57f9006dfa831..3d03fc563370a 100644 --- a/src/ui/public/field_editor/field_editor.js +++ b/src/ui/public/field_editor/field_editor.js @@ -24,12 +24,13 @@ uiModules getField: '&field' }, controllerAs: 'editor', - controller: function ($scope, Notifier, kbnUrl) { + controller: function ($scope, Notifier, kbnUrl, es) { let self = this; let notify = new Notifier({ location: 'Field Editor' }); self.scriptingInfo = scriptingInfo; self.scriptingWarning = scriptingWarning; + self.scriptingLangs = getScriptingLangs(); self.indexPattern = $scope.getIndexPattern(); self.field = shadowCopy($scope.getField()); @@ -129,6 +130,18 @@ uiModules else return fieldFormats.getDefaultType(self.field.type); } + function getScriptingLangs() { + es.cluster.getSettings({ + include_defaults : true, + filter_path : "**.script.engine.*.inline" + }) + .then(function(s) { + self.scriptingLangs = _.keys(_.pick(d.defaults.script.engine, function(e) { + return !!e.inline.search && !!e.inline.aggs + })); + }); + } + function initDefaultFormat() { let def = Object.create(fieldFormats.getDefaultType(self.field.type)); From 99a30ee7ad417c92ac6ba61ba334c532d194a567 Mon Sep 17 00:00:00 2001 From: chenryn Date: Sun, 15 May 2016 13:48:12 +0800 Subject: [PATCH 2/4] modify for eslint delete self.scriptingLangs value assign and correct a typo --- src/ui/public/field_editor/field_editor.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ui/public/field_editor/field_editor.js b/src/ui/public/field_editor/field_editor.js index 3d03fc563370a..801babf53104c 100644 --- a/src/ui/public/field_editor/field_editor.js +++ b/src/ui/public/field_editor/field_editor.js @@ -30,7 +30,7 @@ uiModules self.scriptingInfo = scriptingInfo; self.scriptingWarning = scriptingWarning; - self.scriptingLangs = getScriptingLangs(); + getScriptingLangs(); self.indexPattern = $scope.getIndexPattern(); self.field = shadowCopy($scope.getField()); @@ -133,11 +133,11 @@ uiModules function getScriptingLangs() { es.cluster.getSettings({ include_defaults : true, - filter_path : "**.script.engine.*.inline" + filter_path : '**.script.engine.*.inline' }) - .then(function(s) { - self.scriptingLangs = _.keys(_.pick(d.defaults.script.engine, function(e) { - return !!e.inline.search && !!e.inline.aggs + .then(function (d) { + self.scriptingLangs = _.keys(_.pick(d.defaults.script.engine, function (e) { + return !!e.inline.search && !!e.inline.aggs; })); }); } From 6c8ec66b3ab43875cc1e9c153f45941416700f45 Mon Sep 17 00:00:00 2001 From: Matthew Bargar Date: Sat, 9 Jul 2016 09:40:15 -0400 Subject: [PATCH 3/4] Add a new GET script languages API endpoint To provide additional language options for scripted fields, Kibana needs to know what languages are available for inline scripting in Elasticsearch. This new Kibana API grabs up to date information from Elasticsearch and provides it in an easy to digest format for the UI. The response body from the API is a simple JSON array with a list of languages that are enabled for inline scripting. The API also filters out languages that don't make sense in scripted fields, like 'mustache'. An example request might look like this: `GET /api/kibana/scripts/languages` 200 OK `['expression', 'painless']` --- src/core_plugins/kibana/index.js | 2 ++ .../kibana/server/routes/api/scripts/index.js | 5 ++++ .../routes/api/scripts/register_languages.js | 27 +++++++++++++++++++ test/intern_api.js | 3 ++- test/unit/api/scripts/_languages.js | 27 +++++++++++++++++++ test/unit/api/scripts/index.js | 13 +++++++++ 6 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/core_plugins/kibana/server/routes/api/scripts/index.js create mode 100644 src/core_plugins/kibana/server/routes/api/scripts/register_languages.js create mode 100644 test/unit/api/scripts/_languages.js create mode 100644 test/unit/api/scripts/index.js diff --git a/src/core_plugins/kibana/index.js b/src/core_plugins/kibana/index.js index 6b22f5271fb0a..98fab64495695 100644 --- a/src/core_plugins/kibana/index.js +++ b/src/core_plugins/kibana/index.js @@ -1,6 +1,7 @@ import ingest from './server/routes/api/ingest'; import search from './server/routes/api/search'; import settings from './server/routes/api/settings'; +import scripts from './server/routes/api/scripts'; module.exports = function (kibana) { return new kibana.Plugin({ @@ -84,6 +85,7 @@ module.exports = function (kibana) { ingest(server); search(server); settings(server); + scripts(server); } }); diff --git a/src/core_plugins/kibana/server/routes/api/scripts/index.js b/src/core_plugins/kibana/server/routes/api/scripts/index.js new file mode 100644 index 0000000000000..a625649df423e --- /dev/null +++ b/src/core_plugins/kibana/server/routes/api/scripts/index.js @@ -0,0 +1,5 @@ +import { registerLanguages } from './register_languages'; + +export default function (server) { + registerLanguages(server); +} diff --git a/src/core_plugins/kibana/server/routes/api/scripts/register_languages.js b/src/core_plugins/kibana/server/routes/api/scripts/register_languages.js new file mode 100644 index 0000000000000..82bb5cc9ba22c --- /dev/null +++ b/src/core_plugins/kibana/server/routes/api/scripts/register_languages.js @@ -0,0 +1,27 @@ +import _ from 'lodash'; +import handleESError from '../../../lib/handle_es_error'; + +export function registerLanguages(server) { + server.route({ + path: '/api/kibana/scripts/languages', + method: 'GET', + handler: function (request, reply) { + const callWithRequest = server.plugins.elasticsearch.callWithRequest; + + return callWithRequest(request, 'cluster.getSettings', { + include_defaults: true, + filter_path: '**.script.engine.*.inline' + }) + .then((esResponse) => { + const langs = _.get(esResponse, 'defaults.script.engine', {}); + const inlineLangs = _.pick(langs, (lang) => lang.inline === 'true'); + const supportedLangs = _.omit(inlineLangs, 'mustache'); + return _.keys(supportedLangs); + }) + .then(reply) + .catch((error) => { + reply(handleESError(error)); + }); + } + }); +} diff --git a/test/intern_api.js b/test/intern_api.js index c30303e96c593..08beab27fb3b4 100644 --- a/test/intern_api.js +++ b/test/intern_api.js @@ -1,7 +1,8 @@ define({ suites: [ 'test/unit/api/ingest/index', - 'test/unit/api/search/index' + 'test/unit/api/search/index', + 'test/unit/api/scripts/index' ], excludeInstrumentation: /(fixtures|node_modules)\//, loaderOptions: { diff --git a/test/unit/api/scripts/_languages.js b/test/unit/api/scripts/_languages.js new file mode 100644 index 0000000000000..9f9afa19926eb --- /dev/null +++ b/test/unit/api/scripts/_languages.js @@ -0,0 +1,27 @@ +define(function (require) { + var expect = require('intern/dojo/node!expect.js'); + + return function (bdd, request) { + bdd.describe('Languages API', function getLanguages() { + + bdd.it('should return 200 with an array of languages', function () { + return request.get('/kibana/scripts/languages') + .expect(200) + .then(function (response) { + expect(response.body).to.be.an('array'); + }); + }); + + bdd.it('should only return langs enabled for inline scripting', function () { + return request.get('/kibana/scripts/languages') + .expect(200) + .then(function (response) { + expect(response.body).to.contain('expression'); + expect(response.body).to.contain('painless'); + + expect(response.body).to.not.contain('groovy'); + }); + }); + }); + }; +}); diff --git a/test/unit/api/scripts/index.js b/test/unit/api/scripts/index.js new file mode 100644 index 0000000000000..7b147eec59bb7 --- /dev/null +++ b/test/unit/api/scripts/index.js @@ -0,0 +1,13 @@ +define(function (require) { + var bdd = require('intern!bdd'); + var serverConfig = require('intern/dojo/node!../../../server_config'); + var request = require('intern/dojo/node!supertest-as-promised'); + var url = require('intern/dojo/node!url'); + var languages = require('./_languages'); + + bdd.describe('scripts API', function () { + request = request(url.format(serverConfig.servers.kibana) + '/api'); + + languages(bdd, request); + }); +}); From 2aca107e954e0d9a2005faf532920741bfe751c8 Mon Sep 17 00:00:00 2001 From: Matthew Bargar Date: Sat, 9 Jul 2016 09:55:43 -0400 Subject: [PATCH 4/4] Enable additional scripted field languages This commit allows Kibana scripted fields to be written in any language that has been enabled for inline scripting in ES. By default, that's expression and painless in 5.0. Groovy and other languages can be enabled in the Elasticsearch config. However, I've spent the most time trying to optimize the experience for painless and expression since those are the two sandboxed languages we should be encouraging people to use. Field type options are limited per language based on what makes sense for that language and for scripte fields in general. For instance, expression scripts can only be number fields because expressions only return numbers. No scripted fields can be geo_points, because the geo aggregations Kibana uses don't support scripts. This UI enhancement uses the new script languages API added in the previous commit to get the list of inline scripting languages dynamically. --- src/fixtures/logstash_fields.js | 1 + .../buckets/create_filter/date_histogram.js | 2 +- .../documentation_links.js | 8 ++ .../field_editor/__tests__/field_editor.js | 59 +++++++++++++ src/ui/public/field_editor/field_editor.html | 88 ++++++++++++++++--- src/ui/public/field_editor/field_editor.js | 55 ++++++++---- src/ui/public/field_editor/field_editor.less | 3 + .../public/field_editor/scripting_info.html | 32 ------- .../field_editor/scripting_warning.html | 11 --- .../__tests__/_get_computed_fields.js | 5 +- src/ui/public/index_patterns/_field.js | 2 +- .../index_patterns/_get_computed_fields.js | 2 +- 12 files changed, 192 insertions(+), 76 deletions(-) create mode 100644 src/ui/public/field_editor/field_editor.less delete mode 100644 src/ui/public/field_editor/scripting_info.html delete mode 100644 src/ui/public/field_editor/scripting_warning.html diff --git a/src/fixtures/logstash_fields.js b/src/fixtures/logstash_fields.js index e4f993da81470..824a66ba25094 100644 --- a/src/fixtures/logstash_fields.js +++ b/src/fixtures/logstash_fields.js @@ -22,6 +22,7 @@ function stubbedLogstashFields() { { name: 'custom_user_field', type: 'conflict', indexed: false, analyzed: false, sortable: false, filterable: true }, { name: 'script string', type: 'string', scripted: true, script: '\'i am a string\'', lang: 'expression' }, { name: 'script number', type: 'number', scripted: true, script: '1234', lang: 'expression' }, + { name: 'script date', type: 'date', scripted: true, script: '1234', lang: 'painless' }, { name: 'script murmur3', type: 'murmur3', scripted: true, script: '1234', lang: 'expression'}, ].map(function (field) { field.count = field.count || 0; diff --git a/src/ui/public/agg_types/__tests__/buckets/create_filter/date_histogram.js b/src/ui/public/agg_types/__tests__/buckets/create_filter/date_histogram.js index 9efc4515038aa..76daadfe70b4b 100644 --- a/src/ui/public/agg_types/__tests__/buckets/create_filter/date_histogram.js +++ b/src/ui/public/agg_types/__tests__/buckets/create_filter/date_histogram.js @@ -35,7 +35,7 @@ describe('AggConfig Filters', function () { interval = interval || 'auto'; if (interval === 'custom') interval = agg.params.customInterval; duration = duration || moment.duration(15, 'minutes'); - field = _.sample(indexPattern.fields.byType.date); + field = _.sample(_.reject(indexPattern.fields.byType.date, 'scripted')); vis = new Vis(indexPattern, { type: 'histogram', aggs: [ diff --git a/src/ui/public/documentation_links/documentation_links.js b/src/ui/public/documentation_links/documentation_links.js index b148e90210f1d..36f83e0e969cd 100644 --- a/src/ui/public/documentation_links/documentation_links.js +++ b/src/ui/public/documentation_links/documentation_links.js @@ -14,5 +14,13 @@ export default { elasticsearchOutputAnchorParameters: `${baseUrl}guide/en/beats/filebeat/${urlVersion}/elasticsearch-output.html#_parameters`, startup: `${baseUrl}guide/en/beats/filebeat/${urlVersion}/_step_5_starting_filebeat.html`, exportedFields: `${baseUrl}guide/en/beats/filebeat/${urlVersion}/exported-fields.html` + }, + scriptedFields: { + scriptFields: `${baseUrl}guide/en/elasticsearch/reference/${urlVersion}/search-request-script-fields.html`, + scriptAggs: `${baseUrl}guide/en/elasticsearch/reference/${urlVersion}/search-aggregations.html#_values_source`, + painless: `${baseUrl}guide/en/elasticsearch/reference/${urlVersion}/modules-scripting-painless.html`, + painlessApi: `${baseUrl}guide/en/elasticsearch/reference/${urlVersion}/modules-scripting-painless.html#painless-api`, + painlessSyntax: `${baseUrl}guide/en/elasticsearch/reference/${urlVersion}/modules-scripting-painless-syntax.html`, + luceneExpressions: `${baseUrl}guide/en/elasticsearch/reference/${urlVersion}/modules-scripting-expression.html` } }; diff --git a/src/ui/public/field_editor/__tests__/field_editor.js b/src/ui/public/field_editor/__tests__/field_editor.js index 43b200fde76ca..366fe48ea2b56 100644 --- a/src/ui/public/field_editor/__tests__/field_editor.js +++ b/src/ui/public/field_editor/__tests__/field_editor.js @@ -4,6 +4,8 @@ import expect from 'expect.js'; import IndexPatternsFieldProvider from 'ui/index_patterns/_field'; import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; +import _ from 'lodash'; + describe('FieldEditor directive', function () { let Field; @@ -14,8 +16,15 @@ describe('FieldEditor directive', function () { let $scope; let $el; + let $httpBackend; + beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function ($compile, $injector, Private) { + $httpBackend = $injector.get('$httpBackend'); + $httpBackend + .when('GET', '/api/kibana/scripts/languages') + .respond(['expression', 'painless']); + $rootScope = $injector.get('$rootScope'); Field = Private(IndexPatternsFieldProvider); StringFormat = Private(RegistryFieldFormatsProvider).getType('string'); @@ -127,6 +136,56 @@ describe('FieldEditor directive', function () { }); }); + + describe('scripted fields', function () { + let editor; + let field; + + beforeEach(function () { + $rootScope.field = $rootScope.indexPattern.fields.byName['script string']; + compile(); + editor = $scope.editor; + field = editor.field; + }); + + it('has a scripted flag set to true', function () { + expect(field.scripted).to.be(true); + }); + + it('contains a lang param', function () { + expect(field).to.have.property('lang'); + expect(field.lang).to.be('expression'); + }); + + it('provides lang options based on what is enabled for inline use in ES', function () { + $httpBackend.flush(); + expect(_.isEqual(editor.scriptingLangs, ['expression', 'painless'])).to.be.ok(); + }); + + it('provides curated type options based on language', function () { + $rootScope.$apply(); + expect(editor.fieldTypes).to.have.length(1); + expect(editor.fieldTypes[0]).to.be('number'); + + editor.field.lang = 'painless'; + $rootScope.$apply(); + + expect(editor.fieldTypes).to.have.length(4); + expect(_.isEqual(editor.fieldTypes, ['number', 'string', 'date', 'boolean'])).to.be.ok(); + }); + + it('updates formatter options based on field type', function () { + field.lang = 'painless'; + + $rootScope.$apply(); + expect(editor.field.type).to.be('string'); + const stringFormats = editor.fieldFormatTypes; + + field.type = 'date'; + $rootScope.$apply(); + expect(editor.fieldFormatTypes).to.not.be(stringFormats); + }); + }); }); }); diff --git a/src/ui/public/field_editor/field_editor.html b/src/ui/public/field_editor/field_editor.html index 177cae7e400f0..590d15154981a 100644 --- a/src/ui/public/field_editor/field_editor.html +++ b/src/ui/public/field_editor/field_editor.html @@ -1,4 +1,11 @@
+
+

+ + Scripting disabled: + All inline scripting has been disabled in Elasticsearch. You must enable inline scripting for at least one language in order to use scripted fields in Kibana. +

+
+
+ + +
+
-
- - -
-
- +
-
+
+

+ Proceed with caution +

+ +

+ Please familiarize yourself with script fields and with scripts in aggregations before using scripted fields. +

+ +

+ Scripted fields can be used to display and aggregate calculated values. As such, they can be very slow, and if done incorrectly, can cause Kibana to be unusable. There's no safety net here. If you make a typo, unexpected exceptions will be thrown all over the place! +

+
-
+
+

+ Scripting Help +

+ +

+ By default, Kibana scripted fields use Painless , a simple and secure scripting language designed specifically for use with Elasticsearch. To access values in the document use the following format: +

+ +

doc['some_field'].value

+ +

+ Painless is powerful but easy to use. It provides access to many native Java APIs . Read up on its syntax and you'll be up to speed in no time! +

+ +

+ Coming from an older version of Kibana? The Lucene Expressions you know and love are still available. Lucene expressions are a lot like JavaScript, but limited to basic arithmetic, bitwise and comparison operations. +

+ +

+ There are a few limitations when using Lucene Expressions: +

+
    +
  • Only numeric, boolean, date, and geo_point fields may be accessed
  • +
  • Stored fields are not available
  • +
  • If a field is sparse (only some documents contain a value), documents missing the field will have a value of 0
  • +
+ +

+ Here are all the operations available to lucene expressions: +

+
    +
  • Arithmetic operators: + - * / %
  • +
  • Bitwise operators: | & ^ ~ << >> >>>
  • +
  • Boolean operators (including the ternary operator): && || ! ?:
  • +
  • Comparison operators: < <= == >= >
  • +
  • Common mathematic functions: abs ceil exp floor ln log10 logn max min sqrt pow
  • +
  • Trigonometric library functions: acosh acos asinh asin atanh atan atan2 cosh cos sinh sin tanh tan
  • +
  • Distance functions: haversin
  • +
  • Miscellaneous functions: min, max
  • +
+
diff --git a/src/ui/public/field_editor/field_editor.js b/src/ui/public/field_editor/field_editor.js index 801babf53104c..02a257b81644d 100644 --- a/src/ui/public/field_editor/field_editor.js +++ b/src/ui/public/field_editor/field_editor.js @@ -6,15 +6,22 @@ import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; import IndexPatternsFieldProvider from 'ui/index_patterns/_field'; import uiModules from 'ui/modules'; import fieldEditorTemplate from 'ui/field_editor/field_editor.html'; - +import chrome from 'ui/chrome'; +import IndexPatternsCastMappingTypeProvider from 'ui/index_patterns/_cast_mapping_type'; +import { scriptedFields as docLinks } from '../documentation_links/documentation_links'; +import './field_editor.less'; uiModules .get('kibana', ['colorpicker.module']) .directive('fieldEditor', function (Private, $sce) { let fieldFormats = Private(RegistryFieldFormatsProvider); let Field = Private(IndexPatternsFieldProvider); - let scriptingInfo = $sce.trustAsHtml(require('ui/field_editor/scripting_info.html')); - let scriptingWarning = $sce.trustAsHtml(require('ui/field_editor/scripting_warning.html')); + + const fieldTypesByLang = { + painless: ['number', 'string', 'date', 'boolean'], + expression: ['number'], + default: _.keys(Private(IndexPatternsCastMappingTypeProvider).types.byType) + }; return { restrict: 'E', @@ -24,13 +31,17 @@ uiModules getField: '&field' }, controllerAs: 'editor', - controller: function ($scope, Notifier, kbnUrl, es) { + controller: function ($scope, Notifier, kbnUrl, $http, $q) { let self = this; let notify = new Notifier({ location: 'Field Editor' }); - self.scriptingInfo = scriptingInfo; - self.scriptingWarning = scriptingWarning; - getScriptingLangs(); + self.docLinks = docLinks; + getScriptingLangs().then((langs) => { + self.scriptingLangs = langs; + if (!_.includes(self.scriptingLangs, self.field.lang)) { + self.field.lang = undefined; + } + }); self.indexPattern = $scope.getIndexPattern(); self.field = shadowCopy($scope.getField()); @@ -40,7 +51,6 @@ uiModules self.creating = !self.indexPattern.fields.byName[self.field.name]; self.selectedFormatId = _.get(self.indexPattern, ['fieldFormatMap', self.field.name, 'type', 'id']); self.defFormatType = initDefaultFormat(); - self.fieldFormatTypes = [self.defFormatType].concat(fieldFormats.byFieldType[self.field.type] || []); self.cancel = redirectAway; self.save = function () { @@ -92,6 +102,23 @@ uiModules self.field.format = new FieldFormat(self.formatParams); }, true); + $scope.$watch('editor.field.type', function (newValue) { + self.defFormatType = initDefaultFormat(); + self.fieldFormatTypes = [self.defFormatType].concat(fieldFormats.byFieldType[newValue] || []); + + if (_.isUndefined(_.find(self.fieldFormatTypes, {id: self.selectedFormatId}))) { + delete self.selectedFormatId; + } + }); + + $scope.$watch('editor.field.lang', function (newValue) { + self.fieldTypes = _.get(fieldTypesByLang, newValue, fieldTypesByLang.default); + + if (!_.contains(self.fieldTypes, self.field.type)) { + self.field.type = _.first(self.fieldTypes); + } + }); + // copy the defined properties of the field to a plain object // which is mutable, and capture the changed seperately. function shadowCopy(field) { @@ -131,14 +158,10 @@ uiModules } function getScriptingLangs() { - es.cluster.getSettings({ - include_defaults : true, - filter_path : '**.script.engine.*.inline' - }) - .then(function (d) { - self.scriptingLangs = _.keys(_.pick(d.defaults.script.engine, function (e) { - return !!e.inline.search && !!e.inline.aggs; - })); + return $http.get(chrome.addBasePath('/api/kibana/scripts/languages')) + .then((res) => res.data) + .catch(() => { + return notify.error('Error getting available scripting languages from Elasticsearch'); }); } diff --git a/src/ui/public/field_editor/field_editor.less b/src/ui/public/field_editor/field_editor.less new file mode 100644 index 0000000000000..5b0ad135175eb --- /dev/null +++ b/src/ui/public/field_editor/field_editor.less @@ -0,0 +1,3 @@ +textarea.field-editor_script-input { + height: 100px; +} diff --git a/src/ui/public/field_editor/scripting_info.html b/src/ui/public/field_editor/scripting_info.html deleted file mode 100644 index 0138c01b2c50f..0000000000000 --- a/src/ui/public/field_editor/scripting_info.html +++ /dev/null @@ -1,32 +0,0 @@ -

- Scripting Help -

- -

- By default, Elasticsearch scripts use Lucene Expressions , which is a lot like JavaScript, but limited to basic arithmetic, bitwise and comparison operations. We'll let you do some reading on Lucene Expressions To access values in the document use the following format: -

- -

doc['some_field'].value

- -

- There are a few limitations when using Lucene Expressions: -

- - -

- Here are all the operations available to scripted fields: -

- diff --git a/src/ui/public/field_editor/scripting_warning.html b/src/ui/public/field_editor/scripting_warning.html deleted file mode 100644 index c525c9ee06dc4..0000000000000 --- a/src/ui/public/field_editor/scripting_warning.html +++ /dev/null @@ -1,11 +0,0 @@ -

- Proceed with caution -

- -

- Please familiarize yourself with script fields and with scripts in aggregations before using scripted fields. -

- -

- Scripted fields can be used to display and aggregate calculated values. As such, they can be very slow, and if done incorrectly, can cause Kibana to be unusable. There's no safety net here. If you make a typo, unexpected exceptions will be thrown all over the place! -

diff --git a/src/ui/public/index_patterns/__tests__/_get_computed_fields.js b/src/ui/public/index_patterns/__tests__/_get_computed_fields.js index ae0da4e11978d..ec7e31ae56c94 100644 --- a/src/ui/public/index_patterns/__tests__/_get_computed_fields.js +++ b/src/ui/public/index_patterns/__tests__/_get_computed_fields.js @@ -32,8 +32,11 @@ describe('get computed fields', function () { it('should request date fields as docvalue_fields', function () { expect(fn().docvalueFields).to.contain('@timestamp'); - expect(fn().docvalueFields).to.not.include.keys('bytes'); + expect(fn().docvalueFields).to.not.contain('bytes'); }); + it('should not request scripted date fields as docvalue_fields', function () { + expect(fn().docvalueFields).to.not.contain('script date'); + }); }); diff --git a/src/ui/public/index_patterns/_field.js b/src/ui/public/index_patterns/_field.js index af4471f48feef..986d1fa14ebdd 100644 --- a/src/ui/public/index_patterns/_field.js +++ b/src/ui/public/index_patterns/_field.js @@ -50,7 +50,7 @@ export default function FieldObjectProvider(Private, shortDotsFilter, $rootScope // scripted objs obj.fact('scripted', scripted); obj.writ('script', scripted ? spec.script : null); - obj.writ('lang', scripted ? (spec.lang || 'expression') : null); + obj.writ('lang', scripted ? (spec.lang || 'painless') : null); // mapping info obj.fact('indexed', indexed); diff --git a/src/ui/public/index_patterns/_get_computed_fields.js b/src/ui/public/index_patterns/_get_computed_fields.js index 8730183a60066..50f56eda4c47d 100644 --- a/src/ui/public/index_patterns/_get_computed_fields.js +++ b/src/ui/public/index_patterns/_get_computed_fields.js @@ -6,7 +6,7 @@ export default function () { let scriptFields = {}; let docvalueFields = []; - docvalueFields = _.pluck(self.fields.byType.date, 'name'); + docvalueFields = _.map(_.reject(self.fields.byType.date, 'scripted'), 'name'); _.each(self.getScriptedFields(), function (field) { scriptFields[field.name] = {