Change painless scripted field (#21026) (#21046)

* Change painless scripted field

* Remove wrong char

* Remove invalid escape chars
This commit is contained in:
Nathan Reese 2018-07-20 14:41:52 -06:00 committed by GitHub
parent 126743296f
commit 54d4c5332c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -149,7 +149,11 @@ export default function ({ getService, getPageObjects }) {
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount());
await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
const script = 'doc[\'machine.ram\'].value / (1024 * 1024 * 1024)';
const script = `if (doc['machine.ram'].size() == 0) {
return -1;
} else {
return doc['machine.ram'].value / (1024 * 1024 * 1024);
}`;
await PageObjects.settings.addScriptedField(scriptedPainlessFieldName, 'painless', 'number', null, '1', script);
await retry.try(async function () {
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(startingCount + 1);