Skip to content

Commit

Permalink
[Backport 2.x] Fix bulk API ignores ingest pipeline for upsert (#13055)
Browse files Browse the repository at this point in the history
* Fix bulk API ignores ingest pipeline for upsert (#12883)

* Fix bulk API ignores ingest pipeline for upsert

Signed-off-by: Gao Binlong <[email protected]>

* Modify change log

Signed-off-by: Gao Binlong <[email protected]>

* Use existing pipeline instead

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
(cherry picked from commit f2e8398)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Update 70_bulk.yml

Signed-off-by: Andriy Redko <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Andriy Redko <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andriy Redko <[email protected]>
  • Loading branch information
3 people authored Apr 3, 2024
1 parent 0fe127f commit 90907d4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Removed

### Fixed
- Fix bulk API ignores ingest pipeline for upsert ([#12883](https://github.com/opensearch-project/OpenSearch/pull/12883))
- Fix issue with feature flags where default value may not be honored ([#12849](https://github.com/opensearch-project/OpenSearch/pull/12849))

### Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,26 @@ teardown:

- is_false: _source.field1
- match: {_source.field2: value2}

# related issue: https://github.com/opensearch-project/OpenSearch/issues/12854
---
"Test bulk honors pipeline in update action with upsert":
- skip:
version: " - 2.13.99"
reason: "fixed in 2.14.0"

- do:
bulk:
refresh: true
body:
- '{"update": {"_index": "test_index", "_id": "test_id3", "pipeline": "pipeline1"}}'
- '{"upsert": {"f1": "v2", "f2": 47}, "doc": {"x": 1}}'

- match: { errors: false }
- match: { items.0.update.result: created }

- do:
get:
index: test_index
id: test_id3
- match: { _source: {"f1": "v2", "f2": 47, "field1": "value1"}}
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public void parse(
}
IndexRequest upsertRequest = updateRequest.upsertRequest();
if (upsertRequest != null) {
upsertRequest.setPipeline(defaultPipeline);
upsertRequest.setPipeline(pipeline);
}

updateRequestConsumer.accept(updateRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ public void testUpdateRequest() throws IOException {
parser.parse(request, "foo", null, null, null, true, false, MediaTypeRegistry.JSON, req -> fail(), updateRequest -> {
assertFalse(updateRequest.isRequireAlias());
}, req -> fail());

request = new BytesArray(
"{ \"update\":{ \"_id\": \"bar\", \"require_alias\": false, \"pipeline\": \"testPipeline\" } }\n{\"upsert\": {\"x\": 1}}\n"
);
parser.parse(request, "foo", null, null, null, true, false, MediaTypeRegistry.JSON, req -> fail(), updateRequest -> {
assertEquals(updateRequest.upsertRequest().getPipeline(), "testPipeline");
}, req -> fail());
}

public void testBarfOnLackOfTrailingNewline() {
Expand Down

0 comments on commit 90907d4

Please sign in to comment.