|
40 | 40 | import org.elasticsearch.cluster.node.DiscoveryNode;
|
41 | 41 | import org.elasticsearch.cluster.node.DiscoveryNodes;
|
42 | 42 | import org.elasticsearch.cluster.service.ClusterService;
|
| 43 | +import org.elasticsearch.common.Nullable; |
43 | 44 | import org.elasticsearch.common.collect.ImmutableOpenMap;
|
44 | 45 | import org.elasticsearch.common.settings.ClusterSettings;
|
45 | 46 | import org.elasticsearch.common.settings.Settings;
|
@@ -412,16 +413,29 @@ public void testUseDefaultPipelineWithAlias() throws Exception {
|
412 | 413 | }
|
413 | 414 |
|
414 | 415 | public void testUseDefaultPipelineWithBulkUpsert() throws Exception {
|
| 416 | + String indexRequestName = randomFrom(new String[]{null, WITH_DEFAULT_PIPELINE, WITH_DEFAULT_PIPELINE_ALIAS}); |
| 417 | + validatePipelineWithBulkUpsert(indexRequestName, WITH_DEFAULT_PIPELINE); |
| 418 | + } |
| 419 | + |
| 420 | + public void testUseDefaultPipelineWithBulkUpsertWithAlias() throws Exception { |
| 421 | + String indexRequestName = randomFrom(new String[]{null, WITH_DEFAULT_PIPELINE, WITH_DEFAULT_PIPELINE_ALIAS}); |
| 422 | + validatePipelineWithBulkUpsert(indexRequestName, WITH_DEFAULT_PIPELINE_ALIAS); |
| 423 | + } |
| 424 | + |
| 425 | + private void validatePipelineWithBulkUpsert(@Nullable String indexRequestIndexName, String updateRequestIndexName) throws Exception { |
415 | 426 | Exception exception = new Exception("fake exception");
|
416 | 427 | BulkRequest bulkRequest = new BulkRequest();
|
417 |
| - IndexRequest indexRequest1 = new IndexRequest(WITH_DEFAULT_PIPELINE, "type", "id1").source(Collections.emptyMap()); |
418 |
| - IndexRequest indexRequest2 = new IndexRequest(WITH_DEFAULT_PIPELINE, "type", "id2").source(Collections.emptyMap()); |
419 |
| - IndexRequest indexRequest3 = new IndexRequest(WITH_DEFAULT_PIPELINE, "type", "id3").source(Collections.emptyMap()); |
420 |
| - UpdateRequest upsertRequest = new UpdateRequest(WITH_DEFAULT_PIPELINE, "type", "id1").upsert(indexRequest1).script(mockScript("1")); |
421 |
| - UpdateRequest docAsUpsertRequest = new UpdateRequest(WITH_DEFAULT_PIPELINE, "type", "id2").doc(indexRequest2).docAsUpsert(true); |
| 428 | + IndexRequest indexRequest1 = new IndexRequest(indexRequestIndexName, "type", "id1").source(Collections.emptyMap()); |
| 429 | + IndexRequest indexRequest2 = new IndexRequest(indexRequestIndexName, "type", "id2").source(Collections.emptyMap()); |
| 430 | + IndexRequest indexRequest3 = new IndexRequest(indexRequestIndexName, "type", "id3").source(Collections.emptyMap()); |
| 431 | + UpdateRequest upsertRequest = new UpdateRequest(updateRequestIndexName, "type", "id1") |
| 432 | + .upsert(indexRequest1).script(mockScript("1")); |
| 433 | + UpdateRequest docAsUpsertRequest = new UpdateRequest(updateRequestIndexName, "type", "id2") |
| 434 | + .doc(indexRequest2).docAsUpsert(true); |
422 | 435 | // this test only covers the mechanics that scripted bulk upserts will execute a default pipeline. However, in practice scripted
|
423 | 436 | // bulk upserts with a default pipeline are a bit surprising since the script executes AFTER the pipeline.
|
424 |
| - UpdateRequest scriptedUpsert = new UpdateRequest(WITH_DEFAULT_PIPELINE, "type", "id2").upsert(indexRequest3).script(mockScript("1")) |
| 437 | + UpdateRequest scriptedUpsert = new UpdateRequest(updateRequestIndexName, "type", "id2") |
| 438 | + .upsert(indexRequest3).script(mockScript("1")) |
425 | 439 | .scriptedUpsert(true);
|
426 | 440 | bulkRequest.add(upsertRequest).add(docAsUpsertRequest).add(scriptedUpsert);
|
427 | 441 |
|
|
0 commit comments