企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### Simulate Pipeline API simulate pipeline API通过在请求体中指定多个文档来模拟执行一个pipeline操作. 你也能够通过在请求体中指定多个文档并指定一个存在的pipeline来执行该操作. 以下是请求体中提供的pipeline definition(管道定义)和simulate request(模拟请求)的结构 ~~~ POST _ingest/pipeline/_simulate { "pipeline" : { // pipeline definition here }, "docs" : [ { "_source": {/** first document **/} }, { "_source": {/** second document **/} }, // ... ] } ~~~ 以下是针对已存在 pipeline(管道)的simulate request(模拟请求)的结构 : ~~~ POST _ingest/pipeline/my-pipeline-id/_simulate { "docs" : [ { "_source": {/** first document **/} }, { "_source": {/** second document **/} }, // ... ] } ~~~ 以下是在请求中pipeline definition(管道定义)的simulate request(模拟请求)及其response(响应)的示例 : ~~~ POST _ingest/pipeline/_simulate { "pipeline" : { "description": "_description", "processors": [ { "set" : { "field" : "field2", "value" : "_value" } } ] }, "docs": [ { "_index": "index", "_type": "type", "_id": "id", "_source": { "foo": "bar" } }, { "_index": "index", "_type": "type", "_id": "id", "_source": { "foo": "rab" } } ] } ~~~ 响应结果: ~~~ { "docs": [ { "doc": { "_id": "id", "_index": "index", "_type": "type", "_source": { "field2": "_value", "foo": "bar" }, "_ingest": { "timestamp": "2017-05-04T22:30:03.187Z" } } }, { "doc": { "_id": "id", "_index": "index", "_type": "type", "_source": { "field2": "_value", "foo": "rab" }, "_ingest": { "timestamp": "2017-05-04T22:30:03.188Z" } } } ] } ~~~ ### Viewing Verbose Results 您可以使用simulate pipeline API(模拟管道 API)来了解每个processor是如何来处理ingest document经过pipeline时的细节的。要在simulate request(模拟请求)中查看每个processor的中间结果,可以将该参数verbose添加到请求中。 以下是一个verboserequest(详细请求)及其response(响应)的示例 : ~~~ POST _ingest/pipeline/_simulate?verbose { "pipeline" : { "description": "_description", "processors": [ { "set" : { "field" : "field2", "value" : "_value2" } }, { "set" : { "field" : "field3", "value" : "_value3" } } ] }, "docs": [ { "_index": "index", "_type": "type", "_id": "id", "_source": { "foo": "bar" } }, { "_index": "index", "_type": "type", "_id": "id", "_source": { "foo": "rab" } } ] } ~~~ 响应结果: ~~~ { "docs": [ { "processor_results": [ { "doc": { "_id": "id", "_index": "index", "_type": "type", "_source": { "field2": "_value2", "foo": "bar" }, "_ingest": { "timestamp": "2017-05-04T22:46:09.674Z" } } }, { "doc": { "_id": "id", "_index": "index", "_type": "type", "_source": { "field3": "_value3", "field2": "_value2", "foo": "bar" }, "_ingest": { "timestamp": "2017-05-04T22:46:09.675Z" } } } ] }, { "processor_results": [ { "doc": { "_id": "id", "_index": "index", "_type": "type", "_source": { "field2": "_value2", "foo": "rab" }, "_ingest": { "timestamp": "2017-05-04T22:46:09.676Z" } } }, { "doc": { "_id": "id", "_index": "index", "_type": "type", "_source": { "field3": "_value3", "field2": "_value2", "foo": "rab" }, "_ingest": { "timestamp": "2017-05-04T22:46:09.677Z" } } } ] } ] } ~~~