管道处理器
编辑管道处理器
编辑执行另一个管道。
{ "pipeline": { "name": "inner-pipeline" } }
可以从 _ingest.pipeline
ingest 元数据键访问当前管道的名称。
以下是使用此处理器进行管道嵌套的示例
定义一个内部管道
resp = client.ingest.put_pipeline( id="pipelineA", description="inner pipeline", processors=[ { "set": { "field": "inner_pipeline_set", "value": "inner" } } ], ) print(resp)
response = client.ingest.put_pipeline( id: 'pipelineA', body: { description: 'inner pipeline', processors: [ { set: { field: 'inner_pipeline_set', value: 'inner' } } ] } ) puts response
const response = await client.ingest.putPipeline({ id: "pipelineA", description: "inner pipeline", processors: [ { set: { field: "inner_pipeline_set", value: "inner", }, }, ], }); console.log(response);
PUT _ingest/pipeline/pipelineA { "description" : "inner pipeline", "processors" : [ { "set" : { "field": "inner_pipeline_set", "value": "inner" } } ] }
定义另一个使用先前定义的内部管道的管道
resp = client.ingest.put_pipeline( id="pipelineB", description="outer pipeline", processors=[ { "pipeline": { "name": "pipelineA" } }, { "set": { "field": "outer_pipeline_set", "value": "outer" } } ], ) print(resp)
response = client.ingest.put_pipeline( id: 'pipelineB', body: { description: 'outer pipeline', processors: [ { pipeline: { name: 'pipelineA' } }, { set: { field: 'outer_pipeline_set', value: 'outer' } } ] } ) puts response
const response = await client.ingest.putPipeline({ id: "pipelineB", description: "outer pipeline", processors: [ { pipeline: { name: "pipelineA", }, }, { set: { field: "outer_pipeline_set", value: "outer", }, }, ], }); console.log(response);
PUT _ingest/pipeline/pipelineB { "description" : "outer pipeline", "processors" : [ { "pipeline" : { "name": "pipelineA" } }, { "set" : { "field": "outer_pipeline_set", "value": "outer" } } ] }
现在,在应用外部管道的同时索引文档将看到从外部管道执行的内部管道
resp = client.index( index="my-index-000001", id="1", pipeline="pipelineB", document={ "field": "value" }, ) print(resp)
response = client.index( index: 'my-index-000001', id: 1, pipeline: 'pipelineB', body: { field: 'value' } ) puts response
const response = await client.index({ index: "my-index-000001", id: 1, pipeline: "pipelineB", document: { field: "value", }, }); console.log(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" }