本文整理汇总了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;
}
示例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);
}
}
示例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();
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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));
}
示例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));
}
示例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;
}