-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…2629) * SCRIPTING: Move Aggregation Scripts to their own context
- Loading branch information
1 parent
6a9f418
commit fd87d93
Showing
10 changed files
with
254 additions
and
53 deletions.
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.