Skip to content

Commit

Permalink
Fix update-by-query script examples (#43907)
Browse files Browse the repository at this point in the history
Two examples had swapped the order of lang and code when creating a
script.

Relates #43884
  • Loading branch information
henningandersen committed Aug 22, 2019
1 parent 9d53d64 commit fd8c7b0
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ public void testUpdateByQuery() {
.filter(QueryBuilders.termQuery("level", "awesome"))
.size(1000)
.script(new Script(ScriptType.INLINE,
"ctx._source.awesome = 'absolutely'",
"painless",
"ctx._source.awesome = 'absolutely'",
Collections.emptyMap()));
BulkByScrollResponse response = updateByQuery.get();
// end::update-by-query-filter

// validate order of string params to Script constructor
assertEquals(updateByQuery.request().getScript().getLang(), "painless");
}
{
// tag::update-by-query-size
Expand Down Expand Up @@ -153,16 +156,19 @@ public void testUpdateByQuery() {
updateByQuery.source("source_index")
.script(new Script(
ScriptType.INLINE,
"painless",
"if (ctx._source.awesome == 'absolutely') {"
+ " ctx.op='noop'"
+ "} else if (ctx._source.awesome == 'lame') {"
+ " ctx.op='delete'"
+ "} else {"
+ "ctx._source.awesome = 'absolutely'}",
"painless",
Collections.emptyMap()));
BulkByScrollResponse response = updateByQuery.get();
// end::update-by-query-script

// validate order of string params to Script constructor
assertEquals(updateByQuery.request().getScript().getLang(), "painless");
}
{
// tag::update-by-query-multi-index
Expand Down

0 comments on commit fd8c7b0

Please sign in to comment.