Search in sources :

Example 21 with ScriptEngine

use of org.opensearch.script.ScriptEngine in project OpenSearch by opensearch-project.

the class ScriptedMetricAggregatorTests method getMockScriptService.

@Override
protected ScriptService getMockScriptService() {
    MockScriptEngine scriptEngine = new MockScriptEngine(MockScriptEngine.NAME, SCRIPTS, Collections.emptyMap());
    Map<String, ScriptEngine> engines = Collections.singletonMap(scriptEngine.getType(), scriptEngine);
    return new ScriptService(Settings.EMPTY, engines, ScriptModule.CORE_CONTEXTS);
}
Also used : ScriptService(org.opensearch.script.ScriptService) MockScriptEngine(org.opensearch.script.MockScriptEngine) ScriptEngine(org.opensearch.script.ScriptEngine) MockScriptEngine(org.opensearch.script.MockScriptEngine)

Example 22 with ScriptEngine

use of org.opensearch.script.ScriptEngine in project OpenSearch by opensearch-project.

the class NestedAggregatorTests method getMockScriptService.

@Override
protected ScriptService getMockScriptService() {
    Map<String, Function<Map<String, Object>, Object>> scripts = new HashMap<>();
    scripts.put(INVERSE_SCRIPT, vars -> -((Number) vars.get("_value")).doubleValue());
    MockScriptEngine scriptEngine = new MockScriptEngine(MockScriptEngine.NAME, scripts, Collections.emptyMap());
    Map<String, ScriptEngine> engines = Collections.singletonMap(scriptEngine.getType(), scriptEngine);
    return new ScriptService(Settings.EMPTY, engines, ScriptModule.CORE_CONTEXTS);
}
Also used : ScriptService(org.opensearch.script.ScriptService) Function(java.util.function.Function) HashMap(java.util.HashMap) MockScriptEngine(org.opensearch.script.MockScriptEngine) ScriptEngine(org.opensearch.script.ScriptEngine) MockScriptEngine(org.opensearch.script.MockScriptEngine)

Aggregations

ScriptEngine (org.opensearch.script.ScriptEngine)22 ScriptService (org.opensearch.script.ScriptService)19 MockScriptEngine (org.opensearch.script.MockScriptEngine)18 Function (java.util.function.Function)12 HashMap (java.util.HashMap)10 Settings (org.opensearch.common.settings.Settings)10 Map (java.util.Map)9 IOException (java.io.IOException)8 SortedNumericDocValuesField (org.apache.lucene.document.SortedNumericDocValuesField)8 IndexReader (org.apache.lucene.index.IndexReader)8 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)8 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)8 Directory (org.apache.lucene.store.Directory)8 Script (org.opensearch.script.Script)8 ScriptModule (org.opensearch.script.ScriptModule)8 ScriptType (org.opensearch.script.ScriptType)8 List (java.util.List)7 Consumer (java.util.function.Consumer)7 IndexSearcher (org.apache.lucene.search.IndexSearcher)7 MappedFieldType (org.opensearch.index.mapper.MappedFieldType)7