simulate-pipeline.asciidoc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. [[simulate-pipeline-api]]
  2. === Simulate Pipeline API
  3. The simulate pipeline API executes a specific pipeline against
  4. the set of documents provided in the body of the request.
  5. You can either specify an existing pipeline to execute
  6. against the provided documents, or supply a pipeline definition in
  7. the body of the request.
  8. Here is the structure of a simulate request with a pipeline definition provided
  9. in the body of the request:
  10. [source,js]
  11. --------------------------------------------------
  12. POST _ingest/pipeline/_simulate
  13. {
  14. "pipeline" : {
  15. // pipeline definition here
  16. },
  17. "docs" : [
  18. { "_source": {/** first document **/} },
  19. { "_source": {/** second document **/} },
  20. // ...
  21. ]
  22. }
  23. --------------------------------------------------
  24. // NOTCONSOLE
  25. Here is the structure of a simulate request against an existing pipeline:
  26. [source,js]
  27. --------------------------------------------------
  28. POST _ingest/pipeline/my-pipeline-id/_simulate
  29. {
  30. "docs" : [
  31. { "_source": {/** first document **/} },
  32. { "_source": {/** second document **/} },
  33. // ...
  34. ]
  35. }
  36. --------------------------------------------------
  37. // NOTCONSOLE
  38. Here is an example of a simulate request with a pipeline defined in the request
  39. and its response:
  40. [source,js]
  41. --------------------------------------------------
  42. POST _ingest/pipeline/_simulate
  43. {
  44. "pipeline" :
  45. {
  46. "description": "_description",
  47. "processors": [
  48. {
  49. "set" : {
  50. "field" : "field2",
  51. "value" : "_value"
  52. }
  53. }
  54. ]
  55. },
  56. "docs": [
  57. {
  58. "_index": "index",
  59. "_id": "id",
  60. "_source": {
  61. "foo": "bar"
  62. }
  63. },
  64. {
  65. "_index": "index",
  66. "_id": "id",
  67. "_source": {
  68. "foo": "rab"
  69. }
  70. }
  71. ]
  72. }
  73. --------------------------------------------------
  74. // CONSOLE
  75. Response:
  76. [source,js]
  77. --------------------------------------------------
  78. {
  79. "docs": [
  80. {
  81. "doc": {
  82. "_id": "id",
  83. "_index": "index",
  84. "_type": "_doc",
  85. "_source": {
  86. "field2": "_value",
  87. "foo": "bar"
  88. },
  89. "_ingest": {
  90. "timestamp": "2017-05-04T22:30:03.187Z"
  91. }
  92. }
  93. },
  94. {
  95. "doc": {
  96. "_id": "id",
  97. "_index": "index",
  98. "_type": "_doc",
  99. "_source": {
  100. "field2": "_value",
  101. "foo": "rab"
  102. },
  103. "_ingest": {
  104. "timestamp": "2017-05-04T22:30:03.188Z"
  105. }
  106. }
  107. }
  108. ]
  109. }
  110. --------------------------------------------------
  111. // TESTRESPONSE[s/"2017-05-04T22:30:03.187Z"/$body.docs.0.doc._ingest.timestamp/]
  112. // TESTRESPONSE[s/"2017-05-04T22:30:03.188Z"/$body.docs.1.doc._ingest.timestamp/]
  113. [[ingest-verbose-param]]
  114. ==== Viewing Verbose Results
  115. You can use the simulate pipeline API to see how each processor affects the ingest document
  116. as it passes through the pipeline. To see the intermediate results of
  117. each processor in the simulate request, you can add the `verbose` parameter
  118. to the request.
  119. Here is an example of a verbose request and its response:
  120. [source,js]
  121. --------------------------------------------------
  122. POST _ingest/pipeline/_simulate?verbose
  123. {
  124. "pipeline" :
  125. {
  126. "description": "_description",
  127. "processors": [
  128. {
  129. "set" : {
  130. "field" : "field2",
  131. "value" : "_value2"
  132. }
  133. },
  134. {
  135. "set" : {
  136. "field" : "field3",
  137. "value" : "_value3"
  138. }
  139. }
  140. ]
  141. },
  142. "docs": [
  143. {
  144. "_index": "index",
  145. "_id": "id",
  146. "_source": {
  147. "foo": "bar"
  148. }
  149. },
  150. {
  151. "_index": "index",
  152. "_id": "id",
  153. "_source": {
  154. "foo": "rab"
  155. }
  156. }
  157. ]
  158. }
  159. --------------------------------------------------
  160. // CONSOLE
  161. Response:
  162. [source,js]
  163. --------------------------------------------------
  164. {
  165. "docs": [
  166. {
  167. "processor_results": [
  168. {
  169. "doc": {
  170. "_id": "id",
  171. "_index": "index",
  172. "_type": "_doc",
  173. "_source": {
  174. "field2": "_value2",
  175. "foo": "bar"
  176. },
  177. "_ingest": {
  178. "timestamp": "2017-05-04T22:46:09.674Z"
  179. }
  180. }
  181. },
  182. {
  183. "doc": {
  184. "_id": "id",
  185. "_index": "index",
  186. "_type": "_doc",
  187. "_source": {
  188. "field3": "_value3",
  189. "field2": "_value2",
  190. "foo": "bar"
  191. },
  192. "_ingest": {
  193. "timestamp": "2017-05-04T22:46:09.675Z"
  194. }
  195. }
  196. }
  197. ]
  198. },
  199. {
  200. "processor_results": [
  201. {
  202. "doc": {
  203. "_id": "id",
  204. "_index": "index",
  205. "_type": "_doc",
  206. "_source": {
  207. "field2": "_value2",
  208. "foo": "rab"
  209. },
  210. "_ingest": {
  211. "timestamp": "2017-05-04T22:46:09.676Z"
  212. }
  213. }
  214. },
  215. {
  216. "doc": {
  217. "_id": "id",
  218. "_index": "index",
  219. "_type": "_doc",
  220. "_source": {
  221. "field3": "_value3",
  222. "field2": "_value2",
  223. "foo": "rab"
  224. },
  225. "_ingest": {
  226. "timestamp": "2017-05-04T22:46:09.677Z"
  227. }
  228. }
  229. }
  230. ]
  231. }
  232. ]
  233. }
  234. --------------------------------------------------
  235. // TESTRESPONSE[s/"2017-05-04T22:46:09.674Z"/$body.docs.0.processor_results.0.doc._ingest.timestamp/]
  236. // TESTRESPONSE[s/"2017-05-04T22:46:09.675Z"/$body.docs.0.processor_results.1.doc._ingest.timestamp/]
  237. // TESTRESPONSE[s/"2017-05-04T22:46:09.676Z"/$body.docs.1.processor_results.0.doc._ingest.timestamp/]
  238. // TESTRESPONSE[s/"2017-05-04T22:46:09.677Z"/$body.docs.1.processor_results.1.doc._ingest.timestamp/]