| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 | 
[[simulate-pipeline-api]]=== Simulate Pipeline APIThe simulate pipeline API executes a specific pipeline againstthe set of documents provided in the body of the request.You can either specify an existing pipeline to executeagainst the provided documents, or supply a pipeline definition inthe body of the request.Here is the structure of a simulate request with a pipeline definition providedin the body of the request:[source,js]--------------------------------------------------POST _ingest/pipeline/_simulate{  "pipeline" : {    // pipeline definition here  },  "docs" : [    { "_source": {/** first document **/} },    { "_source": {/** second document **/} },    // ...  ]}--------------------------------------------------// NOTCONSOLEHere is the structure of a simulate request against an existing pipeline:[source,js]--------------------------------------------------POST _ingest/pipeline/my-pipeline-id/_simulate{  "docs" : [    { "_source": {/** first document **/} },    { "_source": {/** second document **/} },    // ...  ]}--------------------------------------------------// NOTCONSOLEHere is an example of a simulate request with a pipeline defined in the requestand its response:[source,js]--------------------------------------------------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"      }    }  ]}--------------------------------------------------// CONSOLEResponse:[source,js]--------------------------------------------------{   "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"            }         }      }   ]}--------------------------------------------------// 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]]==== Viewing Verbose ResultsYou can use the simulate pipeline API to see how each processor affects the ingest documentas it passes through the pipeline. To see the intermediate results ofeach processor in the simulate request, you can add the `verbose` parameterto the request.Here is an example of a verbose request and its response:[source,js]--------------------------------------------------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"      }    }  ]}--------------------------------------------------// CONSOLEResponse:[source,js]--------------------------------------------------{   "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"                  }               }            }         ]      }   ]}--------------------------------------------------// TESTRESPONSE[s/"2017-05-04T22:46:09.674Z"/$body.docs.0.processor_results.0.doc._ingest.timestamp/]// TESTRESPONSE[s/"2017-05-04T22:46:09.675Z"/$body.docs.0.processor_results.1.doc._ingest.timestamp/]// TESTRESPONSE[s/"2017-05-04T22:46:09.676Z"/$body.docs.1.processor_results.0.doc._ingest.timestamp/]// TESTRESPONSE[s/"2017-05-04T22:46:09.677Z"/$body.docs.1.processor_results.1.doc._ingest.timestamp/]
 |