Simulate Pipeline API
editSimulate Pipeline API
editThe simulate pipeline API executes a specific pipeline against the 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.
Here is the structure of a simulate request with a pipeline definition provided in the body of the request:
POST _ingest/pipeline/_simulate { "pipeline" : { // pipeline definition here }, "docs" : [ { "_source": {/** first document **/} }, { "_source": {/** second document **/} }, // ... ] }
Here is the structure of a simulate request against an existing pipeline:
POST _ingest/pipeline/my-pipeline-id/_simulate { "docs" : [ { "_source": {/** first document **/} }, { "_source": {/** second document **/} }, // ... ] }
Here is an example of a simulate request with a pipeline defined in the request and its response:
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" } } ] }
Response:
{ "docs": [ { "doc": { "_id": "id", "_index": "index", "_type": "_doc", "_source": { "field2": "_value", "foo": "bar" }, "_ingest": { "timestamp": "2017-05-04T22:30:03.187Z" } } }, { "doc": { "_id": "id", "_index": "index", "_type": "_doc", "_source": { "field2": "_value", "foo": "rab" }, "_ingest": { "timestamp": "2017-05-04T22:30:03.188Z" } } } ] }
Viewing Verbose Results
editYou 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.
Here is an example of a verbose request and its response:
POST _ingest/pipeline/_simulate?verbose { "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" } } ] }
Response:
{ "docs": [ { "processor_results": [ { "doc": { "_id": "id", "_index": "index", "_type": "_doc", "_source": { "field2": "_value2", "foo": "bar" }, "_ingest": { "timestamp": "2017-05-04T22:46:09.674Z" } } }, { "doc": { "_id": "id", "_index": "index", "_type": "_doc", "_source": { "field3": "_value3", "field2": "_value2", "foo": "bar" }, "_ingest": { "timestamp": "2017-05-04T22:46:09.675Z" } } } ] }, { "processor_results": [ { "doc": { "_id": "id", "_index": "index", "_type": "_doc", "_source": { "field2": "_value2", "foo": "rab" }, "_ingest": { "timestamp": "2017-05-04T22:46:09.676Z" } } }, { "doc": { "_id": "id", "_index": "index", "_type": "_doc", "_source": { "field3": "_value3", "field2": "_value2", "foo": "rab" }, "_ingest": { "timestamp": "2017-05-04T22:46:09.677Z" } } } ] } ] }