Simulate a pipeline Generally available; Added in 5.0.0
All methods and paths for this operation:
GET /_ingest/pipeline/_simulate
POST /_ingest/pipeline/_simulate
GET /_ingest/pipeline/{id}/_simulate
POST /_ingest/pipeline/{id}/_simulate
Run an ingest pipeline against a set of provided documents. You can either specify an existing pipeline to use with the provided documents or supply a pipeline definition in the body of the request.
Required authorization
- Cluster privileges:
read_pipeline
Path parameters
-
The pipeline to test. If you don't specify a
pipeline
in the request body, this parameter is required.
Query parameters
-
If
true
, the response includes output data for each processor in the executed pipeline.
POST /_ingest/pipeline/{id}/_simulate
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" } } ] }
resp = client.ingest.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" } } ], )
const response = await client.ingest.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 = client.ingest.simulate( body: { "pipeline": { "description": "_description", "processors": [ { "set": { "field": "field2", "value": "_value" } } ] }, "docs": [ { "_index": "index", "_id": "id", "_source": { "foo": "bar" } }, { "_index": "index", "_id": "id", "_source": { "foo": "rab" } } ] } )
$resp = $client->ingest()->simulate([ "body" => [ "pipeline" => [ "description" => "_description", "processors" => array( [ "set" => [ "field" => "field2", "value" => "_value", ], ], ), ], "docs" => array( [ "_index" => "index", "_id" => "id", "_source" => [ "foo" => "bar", ], ], [ "_index" => "index", "_id" => "id", "_source" => [ "foo" => "rab", ], ], ), ], ]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"pipeline":{"description":"_description","processors":[{"set":{"field":"field2","value":"_value"}}]},"docs":[{"_index":"index","_id":"id","_source":{"foo":"bar"}},{"_index":"index","_id":"id","_source":{"foo":"rab"}}]}' "$ELASTICSEARCH_URL/_ingest/pipeline/_simulate"
client.ingest().simulate(s -> s .docs(List.of(Document.of(d -> d .id("id") .index("index") .source(JsonData.fromJson("{\"foo\":\"bar\"}"))),Document.of(d -> d .id("id") .index("index") .source(JsonData.fromJson("{\"foo\":\"rab\"}"))))) .pipeline(p -> p .description("_description") .processors(pr -> pr .set(se -> se .field("field2") .value(JsonData.fromJson("\"_value\"")) ) ) ) );
Request example
You can specify the used pipeline either in the request body or as a path parameter.
{ "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 examples (200)
A successful response for running an ingest pipeline against a set of provided documents.
{ "docs": [ { "doc": { "_id": "id", "_index": "index", "_version": "-3", "_source": { "field2": "_value", "foo": "bar" }, "_ingest": { "timestamp": "2017-05-04T22:30:03.187Z" } } }, { "doc": { "_id": "id", "_index": "index", "_version": "-3", "_source": { "field2": "_value", "foo": "rab" }, "_ingest": { "timestamp": "2017-05-04T22:30:03.188Z" } } } ] }