Search in sources :

Example 6 with ScriptType

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

the class UpdateRequest method updateOrCreateScript.

private void updateOrCreateScript(String scriptContent, ScriptType type, String lang, Map<String, Object> params) {
    Script script = script();
    if (script == null) {
        script = new Script(type == null ? ScriptType.INLINE : type, lang, scriptContent == null ? "" : scriptContent, params);
    } else {
        String newScriptContent = scriptContent == null ? script.getIdOrCode() : scriptContent;
        ScriptType newScriptType = type == null ? script.getType() : type;
        String newScriptLang = lang == null ? script.getLang() : lang;
        Map<String, Object> newScriptParams = params == null ? script.getParams() : params;
        script = new Script(newScriptType, newScriptLang, newScriptContent, newScriptParams);
    }
    script(script);
}
Also used : Script(org.opensearch.script.Script) ScriptType(org.opensearch.script.ScriptType) ToXContentObject(org.opensearch.common.xcontent.ToXContentObject)

Aggregations

Script (org.opensearch.script.Script)6 ScriptType (org.opensearch.script.ScriptType)6 HashMap (java.util.HashMap)4 TestUtil.randomSimpleString (org.apache.lucene.tests.util.TestUtil.randomSimpleString)1 IndexRequest (org.opensearch.action.index.IndexRequest)1 BytesReference (org.opensearch.common.bytes.BytesReference)1 ToXContentObject (org.opensearch.common.xcontent.ToXContentObject)1 XContentParser (org.opensearch.common.xcontent.XContentParser)1 XContentType (org.opensearch.common.xcontent.XContentType)1 MockScriptEngine.mockInlineScript (org.opensearch.script.MockScriptEngine.mockInlineScript)1