管道处理器
编辑管道处理器编辑
执行另一个管道。
{ "pipeline": { "name": "inner-pipeline" } }
可以从 _ingest.pipeline
摄取元数据键访问当前管道的名称。
使用此处理器嵌套管道的一个示例是
定义一个内部管道
response = client.ingest.put_pipeline( id: 'pipelineA', body: { description: 'inner pipeline', processors: [ { set: { field: 'inner_pipeline_set', value: 'inner' } } ] } ) puts response
PUT _ingest/pipeline/pipelineA { "description" : "inner pipeline", "processors" : [ { "set" : { "field": "inner_pipeline_set", "value": "inner" } } ] }
定义另一个使用先前定义的内部管道的管道
response = client.ingest.put_pipeline( id: 'pipelineB', body: { description: 'outer pipeline', processors: [ { pipeline: { name: 'pipelineA' } }, { set: { field: 'outer_pipeline_set', value: 'outer' } } ] } ) puts response
PUT _ingest/pipeline/pipelineB { "description" : "outer pipeline", "processors" : [ { "pipeline" : { "name": "pipelineA" } }, { "set" : { "field": "outer_pipeline_set", "value": "outer" } } ] }
现在,在应用外部管道时索引文档将看到从外部管道执行的内部管道
response = client.index( index: 'my-index-000001', id: 1, pipeline: 'pipelineB', body: { field: 'value' } ) puts response
PUT /my-index-000001/_doc/1?pipeline=pipelineB { "field": "value" }
索引请求的响应
{ "_index": "my-index-000001", "_id": "1", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 66, "_primary_term": 1 }
已索引文档
{ "field": "value", "inner_pipeline_set": "inner", "outer_pipeline_set": "outer" }