Search in sources :

Example 1 with DynamicMap

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

the class ConditionalProcessor method evaluate.

boolean evaluate(IngestDocument ingestDocument) {
    IngestConditionalScript script = precompiledConditionScript;
    if (script == null) {
        IngestConditionalScript.Factory factory = scriptService.compile(condition, IngestConditionalScript.CONTEXT);
        script = factory.newInstance(condition.getParams());
    }
    return script.execute(new UnmodifiableIngestData(new DynamicMap(ingestDocument.getSourceAndMetadata(), FUNCTIONS)));
}
Also used : DynamicMap(org.opensearch.script.DynamicMap) IngestConditionalScript(org.opensearch.script.IngestConditionalScript)

Example 2 with DynamicMap

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

the class ScriptProcessor method execute.

/**
 * Executes the script with the Ingest document in context.
 *
 * @param document The Ingest document passed into the script context under the "ctx" object.
 */
@Override
public IngestDocument execute(IngestDocument document) {
    final IngestScript ingestScript;
    if (precompiledIngestScript == null) {
        IngestScript.Factory factory = scriptService.compile(script, IngestScript.CONTEXT);
        ingestScript = factory.newInstance(script.getParams());
    } else {
        ingestScript = precompiledIngestScript;
    }
    ingestScript.execute(new DynamicMap(document.getSourceAndMetadata(), PARAMS_FUNCTIONS));
    CollectionUtils.ensureNoSelfReferences(document.getSourceAndMetadata(), "ingest script");
    return document;
}
Also used : IngestScript(org.opensearch.script.IngestScript) DynamicMap(org.opensearch.script.DynamicMap)

Aggregations

DynamicMap (org.opensearch.script.DynamicMap)2 IngestConditionalScript (org.opensearch.script.IngestConditionalScript)1 IngestScript (org.opensearch.script.IngestScript)1