当前位置: 首页>>代码示例>>Java>>正文


Java ExecutableScript.setNextVar方法代码示例

本文整理汇总了Java中org.elasticsearch.script.ExecutableScript.setNextVar方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutableScript.setNextVar方法的具体用法?Java ExecutableScript.setNextVar怎么用?Java ExecutableScript.setNextVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.script.ExecutableScript的用法示例。


在下文中一共展示了ExecutableScript.setNextVar方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ScriptHeuristic

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
public ScriptHeuristic(ExecutableScript searchScript, Script script) {
    subsetSizeHolder = new LongAccessor();
    supersetSizeHolder = new LongAccessor();
    subsetDfHolder = new LongAccessor();
    supersetDfHolder = new LongAccessor();
    this.searchScript = searchScript;
    if (searchScript != null) {
        searchScript.setNextVar("_subset_freq", subsetDfHolder);
        searchScript.setNextVar("_subset_size", subsetSizeHolder);
        searchScript.setNextVar("_superset_freq", supersetDfHolder);
        searchScript.setNextVar("_superset_size", supersetSizeHolder);
    }
    this.script = script;


}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:ScriptHeuristic.java

示例2: transformSourceAsMap

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Map<String, Object> transformSourceAsMap(Map<String, Object> sourceAsMap) {
    try {
        // We use the ctx variable and the _source name to be consistent with the update api.
        ExecutableScript executable = scriptService.executable(script, ScriptContext.Standard.MAPPING, null, Collections.<String, String>emptyMap());
        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 IllegalArgumentException("failed to execute script", e);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:DocumentMapper.java

示例3: execute

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
/**
 * 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 void execute(IngestDocument document) {
    ExecutableScript executableScript = scriptService.executable(script, ScriptContext.Standard.INGEST);
    executableScript.setNextVar("ctx",  document.getSourceAndMetadata());
    executableScript.run();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ScriptProcessor.java

示例4: testChangingVarsCrossExecution2

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
public void testChangingVarsCrossExecution2() {
    Map<String, Object> vars = new HashMap<>();
    Object compiledScript = scriptEngine.compile(null, "return params['value'];", Collections.emptyMap());

    ExecutableScript script = scriptEngine.executable(new CompiledScript(ScriptType.INLINE,
            "testChangingVarsCrossExecution2", "painless", compiledScript), vars);

    script.setNextVar("value", 1);
    Object value = script.run();
    assertEquals(1, ((Number)value).intValue());

    script.setNextVar("value", 2);
    value = script.run();
    assertEquals(2, ((Number)value).intValue());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:ScriptEngineTests.java

示例5: ExecutableScriptHeuristic

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
ExecutableScriptHeuristic(Script script, ExecutableScript executableScript){
    super(script);
    subsetSizeHolder = new LongAccessor();
    supersetSizeHolder = new LongAccessor();
    subsetDfHolder = new LongAccessor();
    supersetDfHolder = new LongAccessor();
    this.executableScript = executableScript;
    executableScript.setNextVar("_subset_freq", subsetDfHolder);
    executableScript.setNextVar("_subset_size", subsetSizeHolder);
    executableScript.setNextVar("_superset_freq", supersetDfHolder);
    executableScript.setNextVar("_superset_size", supersetSizeHolder);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:ScriptHeuristic.java

示例6: executeScript

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
private Map<String, Object> executeScript(Script script, Map<String, Object> ctx) {
    try {
        if (scriptService != null) {
            ExecutableScript executableScript = scriptService.executable(script, ScriptContext.Standard.UPDATE);
            executableScript.setNextVar("ctx", ctx);
            executableScript.run();
            // we need to unwrap the ctx...
            ctx = (Map<String, Object>) executableScript.unwrap(ctx);
        }
    } catch (Exception e) {
        throw new IllegalArgumentException("failed to execute script", e);
    }
    return ctx;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:UpdateHelper.java

示例7: executeScript

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
private Map<String, Object> executeScript(UpdateRequest request, Map<String, Object> ctx) {
    try {
        if (scriptService != null) {
            ExecutableScript script = scriptService.executable(request.script, ScriptContext.Standard.UPDATE, request, Collections.<String, String>emptyMap());
            script.setNextVar("ctx", ctx);
            script.run();
            // we need to unwrap the ctx...
            ctx = (Map<String, Object>) script.unwrap(ctx);
        }
    } catch (Exception e) {
        throw new IllegalArgumentException("failed to execute script", e);
    }
    return ctx;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:UpdateHelper.java

示例8: testJavaScriptInnerArrayCreation

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
@Test
public void testJavaScriptInnerArrayCreation() {
    Map<String, Object> ctx = new HashMap<String, Object>();
    Map<String, Object> doc = new HashMap<String, Object>();
    ctx.put("doc", doc);

    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));
}
 
开发者ID:jprante,项目名称:elasticsearch-lang-javascript-nashorn,代码行数:16,代码来源:NashornScriptEngineTests.java

示例9: testChangingVarsCrossExecution2

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
@Test
public void testChangingVarsCrossExecution2() {
    Map<String, Object> vars = new HashMap<String, Object>();
    Object compiledScript = se.compile("value");

    ExecutableScript script = se.executable(compiledScript, vars);
    script.setNextVar("value", 1);
    Object o = script.run();
    assertThat(((Number) o).intValue(), equalTo(1));

    script.setNextVar("value", 2);
    o = script.run();
    assertThat(((Number) o).intValue(), equalTo(2));
}
 
开发者ID:jprante,项目名称:elasticsearch-lang-javascript-nashorn,代码行数:15,代码来源:NashornScriptEngineTests.java

示例10: prepareScript

import org.elasticsearch.script.ExecutableScript; //导入方法依赖的package包/类
private ExecutableScript prepareScript(Map<String, Object> ctx) {
	ExecutableScript exe = scriptService.executable(script, ctx);
	exe.setNextVar("ctx", ctx);
	return exe;
}
 
开发者ID:arangodb,项目名称:elasticsearch-river-arangodb,代码行数:6,代码来源:ConcreteUserScript.java


注:本文中的org.elasticsearch.script.ExecutableScript.setNextVar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。