-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Script: Add Metadata to ingest context. #87309
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
Merged
stu-elastic
merged 24 commits into
elastic:master
from
stu-elastic:pain_wfield-ingest-doc-meta
Jun 29, 2022
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
8396488
Script: Add Metadata to ingest context.
stu-elastic 7393951
Update docs/changelog/87309.yaml
stu-elastic a9d6267
spotless
stu-elastic e078901
Merge branch 'pain_wfield-ingest-doc-meta' of github.com:stu-elastic/…
stu-elastic 60a0c96
Merge branch 'master' of github.com:elastic/elasticsearch into pain_w…
stu-elastic f02f66a
use primitive long for version
stu-elastic 502aac2
Merge branch 'master' of github.com:elastic/elasticsearch into pain_w…
stu-elastic e352d3d
meta() -> metadata(), add some javadocs
stu-elastic 699731e
Merge branch 'master' of github.com:elastic/elasticsearch into pain_w…
stu-elastic 41273d0
Remove chaining, remove map size constructor
stu-elastic ae37ff6
rm unused import
stu-elastic ceae2d3
spotless
stu-elastic 43e4b56
remove meta.txt, change Metadata.versionType to a string
stu-elastic 64539fc
Update yamlRestTest with string versionType
stu-elastic 0991e62
Merge branch 'master' of github.com:elastic/elasticsearch into pain_w…
stu-elastic ab51551
rm removeVersion and hasVersion
stu-elastic cda471d
Merge branch 'master' of github.com:elastic/elasticsearch into pain_w…
stu-elastic aa5eb57
Merge branch 'master' of github.com:stu-elastic/elasticsearch into pa…
stu-elastic 8c308c5
Move test and use IngestSourceAndMetadata as Metadata
stu-elastic 5b053da
Merge branch 'master' of github.com:stu-elastic/elasticsearch into pa…
stu-elastic 45cfa2b
Better javadoc on Metadata.java
stu-elastic 942b45d
Metadata doesn't extend Map, pass ctx and Metadata separately
stu-elastic a71a601
Merge branch 'master' of github.com:stu-elastic/elasticsearch into pa…
stu-elastic 8bf32c3
Use getMetadataMap in DotExpanderProcessorTests
stu-elastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 87309 | ||
| summary: "Script: Add Metadata to ingest context" | ||
| area: Infra/Scripting | ||
| type: enhancement | ||
| issues: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| */ | ||
| public abstract class IngestScript { | ||
|
|
||
| public static final String[] PARAMETERS = { "ctx" }; | ||
| public static final String[] PARAMETERS = {}; | ||
|
|
||
| /** The context used to compile {@link IngestScript} factories. */ | ||
| public static final ScriptContext<Factory> CONTEXT = new ScriptContext<>( | ||
|
|
@@ -33,18 +33,36 @@ public abstract class IngestScript { | |
| /** The generic runtime parameters for the script. */ | ||
| private final Map<String, Object> params; | ||
|
|
||
| public IngestScript(Map<String, Object> params) { | ||
| /** The metadata available to the script */ | ||
| private final Metadata metadata; | ||
|
|
||
| /** The metadata and source available to the script */ | ||
| private final Map<String, Object> ctx; | ||
|
|
||
| public IngestScript(Map<String, Object> params, Metadata metadata, Map<String, Object> ctx) { | ||
| this.params = params; | ||
| this.metadata = metadata; | ||
| this.ctx = ctx; | ||
| } | ||
|
|
||
| /** Return the parameters for this script. */ | ||
| public Map<String, Object> getParams() { | ||
| return params; | ||
| } | ||
|
|
||
| public abstract void execute(Map<String, Object> ctx); | ||
| /** Provides backwards compatibility access to ctx */ | ||
| public Map<String, Object> getCtx() { | ||
|
Member
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. Some javadocs would be nice on the new methods here, eg explaing this method provides backcompat for
Contributor
Author
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. Added |
||
| return ctx; | ||
| } | ||
|
|
||
| /** Return the ingest metadata object */ | ||
| public Metadata metadata() { | ||
| return metadata; | ||
| } | ||
|
|
||
| public abstract void execute(); | ||
|
|
||
| public interface Factory { | ||
| IngestScript newInstance(Map<String, Object> params); | ||
| IngestScript newInstance(Map<String, Object> params, Metadata metadata, Map<String, Object> ctx); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this a change in current behavior? It might be worth pulling this out into a separate PR, only so that it can be noted (perhaps as a bugfix) in the release notes, whereas if it goes in within this enhancement/addition to the fields API it would be hidden.
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.
This is the current behavior, it's just the instance used to be cached. This change is due to a failed unit test when I switched to the compiled script rather than the instance.