Skip to content

Commit 596a6c2

Browse files
Fix update-by-query script examples (#43907)
Two examples had swapped the order of lang and code when creating a script. Relates #43884
1 parent 9565516 commit 596a6c2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/reindex/src/test/java/org/elasticsearch/client/documentation/ReindexDocumentationIT.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,14 @@ public void testUpdateByQuery() {
118118
.filter(QueryBuilders.termQuery("level", "awesome"))
119119
.maxDocs(1000)
120120
.script(new Script(ScriptType.INLINE,
121-
"ctx._source.awesome = 'absolutely'",
122121
"painless",
122+
"ctx._source.awesome = 'absolutely'",
123123
Collections.emptyMap()));
124124
BulkByScrollResponse response = updateByQuery.get();
125125
// end::update-by-query-filter
126+
127+
// validate order of string params to Script constructor
128+
assertEquals(updateByQuery.request().getScript().getLang(), "painless");
126129
}
127130
{
128131
// tag::update-by-query-size
@@ -152,16 +155,19 @@ public void testUpdateByQuery() {
152155
updateByQuery.source("source_index")
153156
.script(new Script(
154157
ScriptType.INLINE,
158+
"painless",
155159
"if (ctx._source.awesome == 'absolutely') {"
156160
+ " ctx.op='noop'"
157161
+ "} else if (ctx._source.awesome == 'lame') {"
158162
+ " ctx.op='delete'"
159163
+ "} else {"
160164
+ "ctx._source.awesome = 'absolutely'}",
161-
"painless",
162165
Collections.emptyMap()));
163166
BulkByScrollResponse response = updateByQuery.get();
164167
// end::update-by-query-script
168+
169+
// validate order of string params to Script constructor
170+
assertEquals(updateByQuery.request().getScript().getLang(), "painless");
165171
}
166172
{
167173
// tag::update-by-query-multi-index

0 commit comments

Comments
 (0)