123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439 |
- [[simulate-pipeline-api]]
- === Simulate pipeline API
- ++++
- <titleabbrev>Simulate pipeline</titleabbrev>
- ++++
- Executes an ingest pipeline against
- a set of provided documents.
- ////
- [source,console]
- ----
- PUT /_ingest/pipeline/my-pipeline-id
- {
- "description" : "example pipeline to simulate",
- "processors": [
- {
- "set" : {
- "field" : "field2",
- "value" : "_value"
- }
- }
- ]
- }
- ----
- // TESTSETUP
- ////
- [source,console]
- ----
- POST /_ingest/pipeline/my-pipeline-id/_simulate
- {
- "docs": [
- {
- "_index": "index",
- "_id": "id",
- "_source": {
- "foo": "bar"
- }
- },
- {
- "_index": "index",
- "_id": "id",
- "_source": {
- "foo": "rab"
- }
- }
- ]
- }
- ----
- [[simulate-pipeline-api-request]]
- ==== {api-request-title}
- `POST /_ingest/pipeline/<pipeline>/_simulate`
- `GET /_ingest/pipeline/<pipeline>/_simulate`
- `POST /_ingest/pipeline/_simulate`
- `GET /_ingest/pipeline/_simulate`
- [[simulate-pipeline-api-prereqs]]
- ==== {api-prereq-title}
- * If the {es} {security-features} are enabled, you must have the
- `read_pipeline`, `manage_pipeline`, `manage_ingest_pipelines`, or `manage`
- <<privileges-list-cluster,cluster privilege>> to use this API.
- [[simulate-pipeline-api-desc]]
- ==== {api-description-title}
- The simulate pipeline API executes a specific pipeline
- against a set of documents provided in the body of the request.
- You can either specify an existing pipeline
- to execute against the provided documents
- or supply a pipeline definition in the body of the request.
- [[simulate-pipeline-api-path-params]]
- ==== {api-path-parms-title}
- `<pipeline>`::
- (Required*, string)
- Pipeline to test. If you don't specify a `pipeline` in the request body, this
- parameter is required.
- [[simulate-pipeline-api-query-params]]
- ==== {api-query-parms-title}
- `verbose`::
- (Optional, Boolean)
- If `true`,
- the response includes output data
- for each processor in the executed pipeline.
- [role="child_attributes"]
- [[simulate-pipeline-api-request-body]]
- ==== {api-request-body-title}
- `pipeline`::
- (Required*, object)
- Pipeline to test. If you don't specify the `<pipeline>` request path parameter,
- this parameter is required. If you specify both this and the request path
- parameter, the API only uses the request path parameter.
- +
- .Properties of `pipeline`
- [%collapsible%open]
- ====
- include::put-pipeline.asciidoc[tag=pipeline-object]
- ====
- `docs`::
- (Required, array of objects)
- Sample documents to test in the pipeline.
- +
- .Properties of `docs` objects
- [%collapsible%open]
- ====
- `_id`::
- (Optional, string)
- Unique identifier for the document. This ID must be unique within the `_index`.
- `_index`::
- (Optional, string)
- Name of the index containing the document.
- `_routing`::
- (Optional, string)
- Value used to send the document to a specific primary shard. See the
- <<mapping-routing-field,`_routing`>> field.
- `_source`::
- (Required, object)
- JSON body for the document.
- ====
- [[simulate-pipeline-api-example]]
- ==== {api-examples-title}
- [[simulate-pipeline-api-path-parm-ex]]
- ===== Specify a pipeline as a path parameter
- [source,console]
- ----
- POST /_ingest/pipeline/my-pipeline-id/_simulate
- {
- "docs": [
- {
- "_index": "index",
- "_id": "id",
- "_source": {
- "foo": "bar"
- }
- },
- {
- "_index": "index",
- "_id": "id",
- "_source": {
- "foo": "rab"
- }
- }
- ]
- }
- ----
- The API returns the following response:
- [source,console-result]
- ----
- {
- "docs": [
- {
- "doc": {
- "_id": "id",
- "_index": "index",
- "_source": {
- "field2": "_value",
- "foo": "bar"
- },
- "_ingest": {
- "timestamp": "2017-05-04T22:30:03.187Z"
- }
- }
- },
- {
- "doc": {
- "_id": "id",
- "_index": "index",
- "_source": {
- "field2": "_value",
- "foo": "rab"
- },
- "_ingest": {
- "timestamp": "2017-05-04T22:30:03.188Z"
- }
- }
- }
- ]
- }
- ----
- // TESTRESPONSE[s/"2017-05-04T22:30:03.187Z"/$body.docs.0.doc._ingest.timestamp/]
- // TESTRESPONSE[s/"2017-05-04T22:30:03.188Z"/$body.docs.1.doc._ingest.timestamp/]
- [[simulate-pipeline-api-request-body-ex]]
- ===== Specify a pipeline in the request body
- [source,console]
- ----
- POST /_ingest/pipeline/_simulate
- {
- "pipeline" :
- {
- "description": "_description",
- "processors": [
- {
- "set" : {
- "field" : "field2",
- "value" : "_value"
- }
- }
- ]
- },
- "docs": [
- {
- "_index": "index",
- "_id": "id",
- "_source": {
- "foo": "bar"
- }
- },
- {
- "_index": "index",
- "_id": "id",
- "_source": {
- "foo": "rab"
- }
- }
- ]
- }
- ----
- The API returns the following response:
- [source,console-result]
- ----
- {
- "docs": [
- {
- "doc": {
- "_id": "id",
- "_index": "index",
- "_source": {
- "field2": "_value",
- "foo": "bar"
- },
- "_ingest": {
- "timestamp": "2017-05-04T22:30:03.187Z"
- }
- }
- },
- {
- "doc": {
- "_id": "id",
- "_index": "index",
- "_source": {
- "field2": "_value",
- "foo": "rab"
- },
- "_ingest": {
- "timestamp": "2017-05-04T22:30:03.188Z"
- }
- }
- }
- ]
- }
- ----
- // TESTRESPONSE[s/"2017-05-04T22:30:03.187Z"/$body.docs.0.doc._ingest.timestamp/]
- // TESTRESPONSE[s/"2017-05-04T22:30:03.188Z"/$body.docs.1.doc._ingest.timestamp/]
- [[ingest-verbose-param]]
- ===== View verbose results
- You can use the simulate pipeline API
- to see how each processor affects the ingest document
- as it passes through the pipeline.
- To see the intermediate results
- of each processor in the simulate request,
- you can add the `verbose` parameter to the request.
- [source,console]
- ----
- POST /_ingest/pipeline/_simulate?verbose=true
- {
- "pipeline" :
- {
- "description": "_description",
- "processors": [
- {
- "set" : {
- "field" : "field2",
- "value" : "_value2"
- }
- },
- {
- "set" : {
- "field" : "field3",
- "value" : "_value3"
- }
- }
- ]
- },
- "docs": [
- {
- "_index": "index",
- "_id": "id",
- "_source": {
- "foo": "bar"
- }
- },
- {
- "_index": "index",
- "_id": "id",
- "_source": {
- "foo": "rab"
- }
- }
- ]
- }
- ----
- The API returns the following response:
- [source,console-result]
- ----
- {
- "docs" : [
- {
- "processor_results" : [
- {
- "processor_type" : "set",
- "status" : "success",
- "doc" : {
- "_index" : "index",
- "_id" : "id",
- "_source" : {
- "field2" : "_value2",
- "foo" : "bar"
- },
- "_ingest" : {
- "pipeline" : "_simulate_pipeline",
- "timestamp" : "2020-07-30T01:21:24.251836Z"
- }
- }
- },
- {
- "processor_type" : "set",
- "status" : "success",
- "doc" : {
- "_index" : "index",
- "_id" : "id",
- "_source" : {
- "field3" : "_value3",
- "field2" : "_value2",
- "foo" : "bar"
- },
- "_ingest" : {
- "pipeline" : "_simulate_pipeline",
- "timestamp" : "2020-07-30T01:21:24.251836Z"
- }
- }
- }
- ]
- },
- {
- "processor_results" : [
- {
- "processor_type" : "set",
- "status" : "success",
- "doc" : {
- "_index" : "index",
- "_id" : "id",
- "_source" : {
- "field2" : "_value2",
- "foo" : "rab"
- },
- "_ingest" : {
- "pipeline" : "_simulate_pipeline",
- "timestamp" : "2020-07-30T01:21:24.251863Z"
- }
- }
- },
- {
- "processor_type" : "set",
- "status" : "success",
- "doc" : {
- "_index" : "index",
- "_id" : "id",
- "_source" : {
- "field3" : "_value3",
- "field2" : "_value2",
- "foo" : "rab"
- },
- "_ingest" : {
- "pipeline" : "_simulate_pipeline",
- "timestamp" : "2020-07-30T01:21:24.251863Z"
- }
- }
- }
- ]
- }
- ]
- }
- ----
- // TESTRESPONSE[s/"2020-07-30T01:21:24.251836Z"/$body.docs.0.processor_results.0.doc._ingest.timestamp/]
- // TESTRESPONSE[s/"2020-07-30T01:21:24.251836Z"/$body.docs.0.processor_results.1.doc._ingest.timestamp/]
- // TESTRESPONSE[s/"2020-07-30T01:21:24.251863Z"/$body.docs.1.processor_results.0.doc._ingest.timestamp/]
- // TESTRESPONSE[s/"2020-07-30T01:21:24.251863Z"/$body.docs.1.processor_results.1.doc._ingest.timestamp/]
- ////
- [source,console]
- ----
- DELETE /_ingest/pipeline/*
- ----
- [source,console-result]
- ----
- {
- "acknowledged": true
- }
- ----
- ////
|