-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add templating support to pipeline processor. #49030
Changes from 1 commit
91d8ada
ab43a01
bb8f59c
f02e538
45b794b
bc57fb1
17987ca
eace652
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,25 +19,27 @@ | |
|
||
package org.elasticsearch.ingest; | ||
|
||
import org.elasticsearch.script.TemplateScript; | ||
|
||
import java.util.Map; | ||
import java.util.function.BiConsumer; | ||
|
||
public class PipelineProcessor extends AbstractProcessor { | ||
|
||
public static final String TYPE = "pipeline"; | ||
|
||
private final String pipelineName; | ||
|
||
private final TemplateScript.Factory pipelineName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it make sense to rename this to something that points it to the templating aspect? (eg. |
||
private final IngestService ingestService; | ||
|
||
private PipelineProcessor(String tag, String pipelineName, IngestService ingestService) { | ||
private PipelineProcessor(String tag, TemplateScript.Factory pipelineName, IngestService ingestService) { | ||
super(tag); | ||
this.pipelineName = pipelineName; | ||
this.ingestService = ingestService; | ||
} | ||
|
||
@Override | ||
public void execute(IngestDocument ingestDocument, BiConsumer<IngestDocument, Exception> handler) { | ||
String pipelineName = ingestDocument.renderTemplate(this.pipelineName); | ||
Pipeline pipeline = ingestService.getPipeline(pipelineName); | ||
if (pipeline != null) { | ||
ingestDocument.executePipeline(pipeline, handler); | ||
|
@@ -52,7 +54,8 @@ public IngestDocument execute(IngestDocument ingestDocument) throws Exception { | |
throw new UnsupportedOperationException("this method should not get executed"); | ||
} | ||
|
||
Pipeline getPipeline(){ | ||
Pipeline getPipeline(IngestDocument ingestDocument) { | ||
String pipelineName = ingestDocument.renderTemplate(this.pipelineName); | ||
return ingestService.getPipeline(pipelineName); | ||
} | ||
|
||
|
@@ -61,7 +64,7 @@ public String getType() { | |
return TYPE; | ||
} | ||
|
||
String getPipelineName() { | ||
TemplateScript.Factory getPipelineName() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would avoid a bit of confusion if the getter is renamed to |
||
return pipelineName; | ||
} | ||
|
||
|
@@ -76,9 +79,10 @@ public Factory(IngestService ingestService) { | |
@Override | ||
public PipelineProcessor create(Map<String, Processor.Factory> registry, String processorTag, | ||
Map<String, Object> config) throws Exception { | ||
String pipeline = | ||
ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "name"); | ||
return new PipelineProcessor(processorTag, pipeline, ingestService); | ||
String pipelineNameValue = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "name"); | ||
TemplateScript.Factory pipelineName = | ||
ConfigurationUtils.compileTemplate(TYPE, processorTag, "name", pipelineNameValue, ingestService.getScriptService()); | ||
return new PipelineProcessor(processorTag, pipelineName, ingestService); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have these links changed?
accessing-template-fields
points tocommon-options
andtemplate snippets
to theaccessing template fields
paragraph on thepipeline.asciidoc
page but there isn't such a paragraphThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a direct copy from the set processor docs page and that links correctly. So I think it is good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, might be the github navigation that's not able to follow the links correctly.