@@ -83,11 +83,32 @@ POST /_ingest/_simulate
83
83
}
84
84
]
85
85
}
86
+ },
87
+ "component_template_substitutions": { <2>
88
+ "my-component-template": {
89
+ "template": {
90
+ "mappings": {
91
+ "dynamic": "true",
92
+ "properties": {
93
+ "field3": {
94
+ "type": "keyword"
95
+ }
96
+ }
97
+ },
98
+ "settings": {
99
+ "index": {
100
+ "default_pipeline": "my-pipeline"
101
+ }
102
+ }
103
+ }
104
+ }
86
105
}
87
106
}
88
107
----
89
108
90
109
<1> This replaces the existing `my-pipeline` pipeline with the contents given here for the duration of this request.
110
+ <2> This replaces the existing `my-component-template` component template with the contents given here for the duration of this request.
111
+ These templates can be used to change the pipeline(s) used, or to modify the mapping that will be used to validate the result.
91
112
92
113
[[simulate-ingest-api-request]]
93
114
==== {api-request-title}
@@ -191,6 +212,19 @@ Map of pipeline IDs to substitute pipeline definition objects.
191
212
include::put-pipeline.asciidoc[tag=pipeline-object]
192
213
====
193
214
215
+ `component_template_substitutions`::
216
+ (Optional, map of strings to objects)
217
+ Map of component template names to substitute component template definition objects.
218
+ +
219
+ .Properties of component template definition objects
220
+ [%collapsible%open]
221
+
222
+ ====
223
+
224
+ include::{es-ref-dir}/indices/put-component-template.asciidoc[tag=template]
225
+
226
+ ====
227
+
194
228
[[simulate-ingest-api-example]]
195
229
==== {api-examples-title}
196
230
@@ -268,7 +302,7 @@ The API returns the following response:
268
302
269
303
[[simulate-ingest-api-request-body-ex]]
270
304
===== Specify a pipeline substitution in the request body
271
- In this example the index `index` has a default pipeline called `my-pipeline` and a final
305
+ In this example the index `my- index` has a default pipeline called `my-pipeline` and a final
272
306
pipeline called `my-final-pipeline`. But a substitute definition of `my-pipeline` is
273
307
provided in `pipeline_substitutions`. The substitute `my-pipeline` will be used in place of
274
308
the `my-pipeline` that is in the system, and then the `my-final-pipeline` that is already
@@ -348,6 +382,87 @@ The API returns the following response:
348
382
}
349
383
----
350
384
385
+ [[simulate-ingest-api-substitute-component-templates-ex]]
386
+ ===== Specify a component template substitution in the request body
387
+ In this example, imagine that the index `my-index` has a strict mapping with only the `foo`
388
+ keyword field defined. Say that field mapping came from a component template named
389
+ `my-mappings-template`. We want to test adding a new field, `bar`. So a substitute definition of
390
+ `my-mappings-template` is provided in `component_template_substitutions`. The substitute
391
+ `my-mappings-template` will be used in place of the existing mapping for `my-index` and in place
392
+ of the `my-mappings-template` that is in the system.
393
+
394
+ [source,console]
395
+ ----
396
+ POST /_ingest/_simulate
397
+ {
398
+ "docs": [
399
+ {
400
+ "_index": "my-index",
401
+ "_id": "123",
402
+ "_source": {
403
+ "foo": "foo"
404
+ }
405
+ },
406
+ {
407
+ "_index": "my-index",
408
+ "_id": "456",
409
+ "_source": {
410
+ "bar": "rab"
411
+ }
412
+ }
413
+ ],
414
+ "component_template_substitutions": {
415
+ "my-mappings_template": {
416
+ "template": {
417
+ "mappings": {
418
+ "dynamic": "strict",
419
+ "properties": {
420
+ "foo": {
421
+ "type": "keyword"
422
+ },
423
+ "bar": {
424
+ "type": "keyword"
425
+ }
426
+ }
427
+ }
428
+ }
429
+ }
430
+ }
431
+ }
432
+ ----
433
+
434
+ The API returns the following response:
435
+
436
+ [source,console-result]
437
+ ----
438
+ {
439
+ "docs": [
440
+ {
441
+ "doc": {
442
+ "_id": "123",
443
+ "_index": "my-index",
444
+ "_version": -3,
445
+ "_source": {
446
+ "foo": "foo"
447
+ },
448
+ "executed_pipelines": []
449
+ }
450
+ },
451
+ {
452
+ "doc": {
453
+ "_id": "456",
454
+ "_index": "my-index",
455
+ "_version": -3,
456
+ "_source": {
457
+ "bar": "rab"
458
+ },
459
+ "executed_pipelines": []
460
+ }
461
+ }
462
+ ]
463
+ }
464
+ ----
465
+
351
466
////
352
467
[source,console]
353
468
----
0 commit comments