-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Replace Ingest ScriptContext with Custom Interface #32003
Changes from 1 commit
807b3b2
ada26d7
89874c9
fb9647d
7d085cb
b1f7d43
c35c213
b647352
762d2f7
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.script; | ||
|
||
import java.util.Map; | ||
|
||
public abstract class IngestScript { | ||
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. maybe add class level java docs here? 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. Sounds good, added in 762d2f7 :) |
||
|
||
public static final String[] PARAMETERS = { "ctx" }; | ||
|
||
/** The context used to compile {@link IngestScript} factories. */ | ||
public static final ScriptContext<Factory> CONTEXT = new ScriptContext<>("ingest", Factory.class); | ||
|
||
/** The generic runtime parameters for the script. */ | ||
private final Map<String, Object> params; | ||
|
||
public IngestScript(Map<String, Object> params) { | ||
this.params = params; | ||
} | ||
|
||
/** Return the parameters for this script. */ | ||
public Map<String, Object> getParams() { | ||
return params; | ||
} | ||
|
||
public abstract void execute(Map<String, Object> ctx); | ||
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. While this will be needed for backcompat in 6.x, I think we want to expose IngestDocument as a variable directly here. But this can be done as a followup (along with deprecation control of the old ctx variable). |
||
|
||
public interface Factory { | ||
IngestScript newInstance(Map<String, Object> params); | ||
} | ||
} |
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.
one thing we do not check here is that the Map passed in as the ctx is actually
Do you think that would be useful here?
We do have checks in
rest-api-spec/test/ingest/50_script_processor_using_painless.yml
that we are actually modifying the document, so that may be sufficient. Seems like it would be nice to validate this from unit tests tooThere 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.
@talevy makes sense + is trivial to do => sec adjusting :)
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.
@talevy done in 89874c9 :)
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.
cooool. thanks!