Skip to content

Commit 8a59ca1

Browse files
Support system ingest pipelines for bulk update operations (opensearch-project#18277)
* Support system ingest pipelines for bulk update operations Signed-off-by: Andy Qin <[email protected]> * Spotless Signed-off-by: Andy Qin <[email protected]> # Conflicts: # CHANGELOG.md * Refactor UpdateRequest type checking Signed-off-by: Andy Qin <[email protected]> * Fix integ tests after rebase Signed-off-by: Andy Qin <[email protected]> * Rename innerSlot to childSlot Signed-off-by: Andy Qin <[email protected]> * Update yaml tests Signed-off-by: Andy Qin <[email protected]> * Update comments Signed-off-by: Andy Qin <[email protected]> * Add allowed warning header for yaml tests Signed-off-by: Andy Qin <[email protected]> * Update warning headers Signed-off-by: Andy Qin <[email protected]> --------- Signed-off-by: Andy Qin <[email protected]> Signed-off-by: Sarat Vemulapalli <[email protected]> Co-authored-by: Sarat Vemulapalli <[email protected]>
1 parent c92b8ea commit 8a59ca1

File tree

20 files changed

+904
-144
lines changed

20 files changed

+904
-144
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4949
- Added node-left metric to cluster manager ([#18421](https://github.com/opensearch-project/OpenSearch/pull/18421))
5050
- [Star tree] Remove star tree feature flag and add index setting to configure star tree search on index basis ([#18070](https://github.com/opensearch-project/OpenSearch/pull/18070))
5151
- Approximation Framework Enhancement: Update the BKD traversal logic to improve the performance on skewed data ([#18439](https://github.com/opensearch-project/OpenSearch/issues/18439))
52+
- Support system generated ingest pipelines for bulk update operations ([#18277](https://github.com/opensearch-project/OpenSearch/pull/18277)))
5253
- Added FS Health Check Failure metric ([#18435](https://github.com/opensearch-project/OpenSearch/pull/18435))
5354

5455
### Changed

plugins/examples/mapping-transformer/src/yamlRestTest/resources/rest-api-spec/test/example-mapping-transformer/20_mapping_transformer.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@
3939

4040
---
4141
"Test auto-injected field via index template":
42+
- skip:
43+
features: allowed_warnings
4244
- do:
45+
allowed_warnings:
46+
- "index template [example_template] has index patterns [auto-template-*] matching patterns from existing older templates [global] with patterns (global => [*]); this template [example_template] will take precedence during new index creation"
4347
indices.put_index_template:
4448
name: example_template
4549
body:
@@ -62,6 +66,8 @@
6266

6367
---
6468
"Test auto-injected field via legacy create template API":
69+
- skip:
70+
features: allowed_warnings
6571
- do:
6672
indices.put_template:
6773
name: legacy_template
@@ -72,6 +78,8 @@
7278
mapping_transform_trigger_field:
7379
type: keyword
7480
- do:
81+
allowed_warnings:
82+
- "index [legacy-1] matches multiple legacy templates [global, legacy_template], composable templates will only match a single template"
7583
indices.create:
7684
index: legacy-1
7785
- do:

plugins/examples/system-ingest-processor/src/test/java/org/opensearch/example/systemingestprocessor/ExampleSystemIngestProcessorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void testSubBatchExecute() {
4444

4545
private IngestDocumentWrapper createIngestDocumentWrapper(int slot) {
4646
final IngestDocument ingestDocument = new IngestDocument(new HashMap<>(), new HashMap<>());
47-
return new IngestDocumentWrapper(slot, ingestDocument, null);
47+
return new IngestDocumentWrapper(slot, 0, ingestDocument, null);
4848
}
4949

5050
public void testGetType() {

plugins/examples/system-ingest-processor/src/yamlRestTest/resources/rest-api-spec/test/example-system-ingest-processor/20_system_ingest_processor.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
teardown:
2+
- do:
3+
cluster.put_settings:
4+
body:
5+
persistent:
6+
cluster.ingest.system_pipeline_enabled: "true"
7+
18
---
29
"Processor injects a field on indexing a doc to existing index":
310
- do:
@@ -106,6 +113,8 @@
106113

107114
---
108115
"Processor injects field on bulk index to non-existent index matching template":
116+
- skip:
117+
features: allowed_warnings
109118
- do:
110119
indices.put_template:
111120
name: bulk-template
@@ -116,6 +125,8 @@
116125
system_ingest_processor_trigger_field:
117126
type: keyword
118127
- do:
128+
allowed_warnings:
129+
- "index [bulk-template-index-1] matches multiple legacy templates [bulk-template, global], composable templates will only match a single template"
119130
bulk:
120131
refresh: true
121132
body:
@@ -141,3 +152,135 @@
141152
id: 2
142153
- match:
143154
_source.field_auto_added_by_system_ingest_processor: "This field is auto added by the example system ingest processor."
155+
156+
---
157+
"Processor injects field on bulk update, upsert on existing/new documents":
158+
# Temporarily disable system ingest pipelines to insert without triggering the system ingest field
159+
- do:
160+
cluster.put_settings:
161+
body:
162+
persistent:
163+
cluster.ingest.system_pipeline_enabled: "false"
164+
165+
- do:
166+
indices.create:
167+
index: bulk-index
168+
body:
169+
mappings:
170+
properties:
171+
system_ingest_processor_trigger_field:
172+
type: keyword
173+
174+
# Index documents to be updated on later step
175+
- do:
176+
bulk:
177+
refresh: true
178+
body:
179+
- index:
180+
_index: bulk-index
181+
_id: "1"
182+
- system_ingest_processor_trigger_field: "bulk1"
183+
- index:
184+
_index: bulk-index
185+
_id: "2"
186+
- system_ingest_processor_trigger_field: "bulk2"
187+
- index:
188+
_index: bulk-index
189+
_id: "3"
190+
- system_ingest_processor_trigger_field: "bulk3"
191+
192+
# Verify system ingest pipelines weren't triggered on regular index operations
193+
- do:
194+
get:
195+
index: bulk-index
196+
id: 1
197+
- match:
198+
_source.field_auto_added_by_system_ingest_processor: null
199+
200+
- do:
201+
get:
202+
index: bulk-index
203+
id: 2
204+
- match:
205+
_source.field_auto_added_by_system_ingest_processor: null
206+
207+
- do:
208+
get:
209+
index: bulk-index
210+
id: 2
211+
- match:
212+
_source.field_auto_added_by_system_ingest_processor: null
213+
214+
# Reenable system ingest pipeline
215+
- do:
216+
cluster.put_settings:
217+
body:
218+
persistent:
219+
cluster.ingest.system_pipeline_enabled: "true"
220+
221+
# Bulk update, bulk upsert existing, and bulk upsert new should all trigger ingest pipelines
222+
- do:
223+
bulk:
224+
refresh: true
225+
body:
226+
- update:
227+
_index: bulk-index
228+
_id: "1"
229+
- doc:
230+
system_ingest_processor_trigger_field: "update bulk1"
231+
- update:
232+
_index: bulk-index
233+
_id: "2"
234+
- doc:
235+
system_ingest_processor_trigger_field: "update bulk2"
236+
upsert:
237+
system_ingest_processor_trigger_field: "new upsert bulk2"
238+
- update:
239+
_index: bulk-index
240+
_id: "3"
241+
- doc:
242+
system_ingest_processor_trigger_field: "doc as upsert bulk3"
243+
doc_as_upsert: true
244+
- update:
245+
_index: bulk-index
246+
_id: "4"
247+
- doc:
248+
system_ingest_processor_trigger_field: "update bulk4"
249+
upsert:
250+
system_ingest_processor_trigger_field: "new upsert bulk4"
251+
252+
- do:
253+
get:
254+
index: bulk-index
255+
id: 1
256+
- match:
257+
_source.field_auto_added_by_system_ingest_processor: "This field is auto added by the example system ingest processor."
258+
- match:
259+
_source.system_ingest_processor_trigger_field: "update bulk1"
260+
261+
- do:
262+
get:
263+
index: bulk-index
264+
id: 2
265+
- match:
266+
_source.field_auto_added_by_system_ingest_processor: "This field is auto added by the example system ingest processor."
267+
- match:
268+
_source.system_ingest_processor_trigger_field: "update bulk2"
269+
270+
- do:
271+
get:
272+
index: bulk-index
273+
id: 3
274+
- match:
275+
_source.field_auto_added_by_system_ingest_processor: "This field is auto added by the example system ingest processor."
276+
- match:
277+
_source.system_ingest_processor_trigger_field: "doc as upsert bulk3"
278+
279+
- do:
280+
get:
281+
index: bulk-index
282+
id: 4
283+
- match:
284+
_source.field_auto_added_by_system_ingest_processor: "This field is auto added by the example system ingest processor."
285+
- match:
286+
_source.system_ingest_processor_trigger_field: "new upsert bulk4"

0 commit comments

Comments
 (0)