-
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
SCRIPTING: Move Aggregation Scripts to their own context #32068
Merged
original-brownbear
merged 25 commits into
elastic:master
from
original-brownbear:replace-agg-script-context
Aug 4, 2018
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
2ee4b46
SCRIPTING: Move Aggregation Scripts to their own context
original-brownbear 5088757
Merge remote-tracking branch 'elastic/master' into replace-agg-script…
original-brownbear f924c07
Merge remote-tracking branch 'elastic/master' into replace-agg-script…
original-brownbear de9b238
CR: Make returns typed
original-brownbear 2ac53ab
CR: Make returns typed
original-brownbear 0386ec8
CR: Make returns typed
original-brownbear 574780d
Merge remote-tracking branch 'elastic/master' into replace-agg-script…
original-brownbear 63963f6
CR: Make returns typed
original-brownbear ba8fd94
CR: Make returns typed
original-brownbear 678d388
Merge branch 'master' into replace-agg-script-context
original-brownbear 145e11f
Renamings from CR
original-brownbear 05e6559
Merge remote-tracking branch 'elastic/master' into replace-agg-script…
original-brownbear bc27466
CR: Make BucketSelectorPipelineAggregator agnositc to lang
original-brownbear 0f13633
CR: Make BucketSelectorPipelineAggregator agnositic to language
original-brownbear a1bd389
CR: Add separate context for scriptheuristic
original-brownbear af67738
CR: Add separate context for scriptheuristic
original-brownbear b0a4487
CR: Add separate context for scriptheuristic
original-brownbear 2662c87
CR: Add separate context for scriptheuristic
original-brownbear f31660c
Merge remote-tracking branch 'elastic/master' into replace-agg-script…
original-brownbear d506e97
CR: Move params to script field
original-brownbear 5a55338
CR: Move params to script field
original-brownbear 956480e
Merge remote-tracking branch 'elastic/master' into replace-agg-script…
original-brownbear b095f3d
CR: Move params to script field
original-brownbear 5bf4573
Merge remote-tracking branch 'elastic/master' into replace-agg-script…
original-brownbear 6509e85
CR: Rename heuristic score script
original-brownbear 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 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
54 changes: 54 additions & 0 deletions
54
server/src/main/java/org/elasticsearch/script/BucketAggregationScript.java
This file contains 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,54 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* A script used in bucket aggregations that returns a {@code double} value. | ||
*/ | ||
public abstract class BucketAggregationScript { | ||
|
||
public static final String[] PARAMETERS = {}; | ||
|
||
public static final ScriptContext<Factory> CONTEXT = new ScriptContext<>("bucket_aggregation", Factory.class); | ||
|
||
/** | ||
* The generic runtime parameters for the script. | ||
*/ | ||
private final Map<String, Object> params; | ||
|
||
public BucketAggregationScript(Map<String, Object> params) { | ||
this.params = params; | ||
} | ||
|
||
/** | ||
* Return the parameters for this script. | ||
*/ | ||
public Map<String, Object> getParams() { | ||
return params; | ||
} | ||
|
||
public abstract double execute(); | ||
|
||
public interface Factory { | ||
BucketAggregationScript newInstance(Map<String, Object> params); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
server/src/main/java/org/elasticsearch/script/BucketAggregationSelectorScript.java
This file contains 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,54 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* A script used in bucket aggregations that returns a {@code boolean} value. | ||
*/ | ||
public abstract class BucketAggregationSelectorScript { | ||
|
||
public static final String[] PARAMETERS = {}; | ||
|
||
public static final ScriptContext<Factory> CONTEXT = new ScriptContext<>("aggregation_selector", Factory.class); | ||
|
||
/** | ||
* The generic runtime parameters for the script. | ||
*/ | ||
private final Map<String, Object> params; | ||
|
||
public BucketAggregationSelectorScript(Map<String, Object> params) { | ||
this.params = params; | ||
} | ||
|
||
/** | ||
* Return the parameters for this script. | ||
*/ | ||
public Map<String, Object> getParams() { | ||
return params; | ||
} | ||
|
||
public abstract boolean execute(); | ||
|
||
public interface Factory { | ||
BucketAggregationSelectorScript newInstance(Map<String, Object> params); | ||
} | ||
} |
This file contains 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 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
38 changes: 38 additions & 0 deletions
38
server/src/main/java/org/elasticsearch/script/SignificantTermsHeuristicScoreScript.java
This file contains 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,38 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* A script used in significant terms heuristic scoring. | ||
*/ | ||
public abstract class SignificantTermsHeuristicScoreScript { | ||
|
||
public static final String[] PARAMETERS = { "params" }; | ||
|
||
public static final ScriptContext<Factory> CONTEXT = new ScriptContext<>("script_heuristic", Factory.class); | ||
|
||
public abstract double execute(Map<String, Object> params); | ||
|
||
public interface Factory { | ||
SignificantTermsHeuristicScoreScript newInstance(); | ||
} | ||
} |
This file contains 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
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.
I think this should be its own context. Putting these into params would be a breaking change, and also not utilize the intent of having contexts (different variables for different uses).
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.
@rjernst but currently these are documented as
params
aren't they? See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html#_scriptedAlso under the hood
org.elasticsearch.painless.ScriptImpl
simply puts these underparams
, these aren't available as top level params are they?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.
You are right, I was confused because of what I saw in ScriptImpl for painless (naming implying it was in variables for the script, but that is actually the params). I still think this needs to be its own context. We can eventually move these to direct arguments of the execute method (again, so params can be read-only in the future).
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.
@rjernst Made this a separate context now in a1bd389
Didn't add any further logic for making these direct parameters yet though or did we want to add that here already?
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.
They can be added as direct arguments in a separate PR. There should also be deprecation messages along with that so we can remove inserting them into params.