Package org.elasticsearch.script

Examples of org.elasticsearch.script.ExecutableScript.unwrap()


        Object complied = se.compile("ctx.doc.field1 = ['value1', 'value2']");
        ExecutableScript script = se.executable(complied, new HashMap<String, Object>());
        script.setNextVar("ctx", ctx);
        script.run();

        Map<String, Object> unwrap = (Map<String, Object>) script.unwrap(ctx);

        assertThat(((Map) unwrap.get("doc")).get("field1"), instanceOf(List.class));
    }

    @Test public void testAccessListInScript() {
View Full Code Here


        Object complied = se.compile("ctx.doc.field1 = ['value1', 'value2']");
        ExecutableScript script = se.executable(complied, new HashMap<String, Object>());
        script.setNextVar("ctx", ctx);
        script.run();

        Map<String, Object> unwrap = (Map<String, Object>) script.unwrap(ctx);

        assertThat(((Map) unwrap.get("doc")).get("field1"), instanceOf(List.class));
    }

    @Test
View Full Code Here

                    ExecutableScript executableScript = scriptService.executable(definition.getScriptType(), definition.getScript(),
                            ScriptService.ScriptType.INLINE, ImmutableMap.of("logger", logger));
                    executableScript.setNextVar("ctx", ctx);
                    executableScript.run();
                    // we need to unwrap the context object...
                    ctx = (Map<String, Object>) executableScript.unwrap(ctx);
                } catch (Exception e) {
                    logger.warn("failed to script process {}, ignoring", e, ctx);
                    MongoDBRiverHelper.setRiverStatus(esClient, definition.getRiverName(), Status.SCRIPT_IMPORT_FAILED);
                }
                if (logger.isTraceEnabled()) {
View Full Code Here

                        logger.trace("Context before script executed: {}", ctx);
                    }
                    executableScript.setNextVar("ctx", ctx);
                    executableScript.run();
                    // we need to unwrap the context object...
                    ctx = (Map<String, Object>) executableScript.unwrap(ctx);
                } catch (Exception e) {
                    logger.error("failed to script process {}, ignoring", e, ctx);
                    MongoDBRiverHelper.setRiverStatus(esClient, definition.getRiverName(), Status.SCRIPT_IMPORT_FAILED);
                }
                if (logger.isTraceEnabled()) {
View Full Code Here

                ExecutableScript executable = scriptService.executable(language, script, scriptType, parameters);
                Map<String, Object> ctx = new HashMap<>(1);
                ctx.put("_source", sourceAsMap);
                executable.setNextVar("ctx", ctx);
                executable.run();
                ctx = (Map<String, Object>) executable.unwrap(ctx);
                return (Map<String, Object>) ctx.get("_source");
            } catch (Exception e) {
                throw new ElasticsearchIllegalArgumentException("failed to execute script", e);
            }
        }
View Full Code Here

                try {
                    ExecutableScript script = scriptService.executable(request.scriptLang, request.script, request.scriptType, request.scriptParams);
                    script.setNextVar("ctx", ctx);
                    script.run();
                    // we need to unwrap the ctx...
                    ctx = (Map<String, Object>) script.unwrap(ctx);
                } catch (Exception e) {
                    throw new ElasticsearchIllegalArgumentException("failed to execute script", e);
                }               
                //Allow the script to set TTL using ctx._ttl
                ttl = getTTLFromScriptContext(ctx);
View Full Code Here

            try {
                ExecutableScript script = scriptService.executable(request.scriptLang, request.script, request.scriptType, request.scriptParams);
                script.setNextVar("ctx", ctx);
                script.run();
                // we need to unwrap the ctx...
                ctx = (Map<String, Object>) script.unwrap(ctx);
            } catch (Exception e) {
                throw new ElasticsearchIllegalArgumentException("failed to execute script", e);
            }

            operation = (String) ctx.get("op");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.