本文整理汇总了Java中org.elasticsearch.script.CompiledScript.compiled方法的典型用法代码示例。如果您正苦于以下问题:Java CompiledScript.compiled方法的具体用法?Java CompiledScript.compiled怎么用?Java CompiledScript.compiled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.script.CompiledScript
的用法示例。
在下文中一共展示了CompiledScript.compiled方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: search
import org.elasticsearch.script.CompiledScript; //导入方法依赖的package包/类
/**
* Retrieve a {@link SearchScript} for later use.
* @param compiledScript A previously compiled script.
* @param lookup The object that ultimately allows access to search fields.
* @param vars The variables to be used in the script.
* @return An {@link SearchScript} with the currently specified variables.
*/
@Override
public SearchScript search(final CompiledScript compiledScript, final SearchLookup lookup, final Map<String, Object> vars) {
return new SearchScript() {
/**
* Get the search script that will have access to search field values.
* @param context The LeafReaderContext to be used.
* @return A script that will have the search fields from the current context available for use.
*/
@Override
public LeafSearchScript getLeafSearchScript(final LeafReaderContext context) throws IOException {
return new ScriptImpl((GenericElasticsearchScript) compiledScript.compiled(), vars, lookup.getLeafSearchLookup(context));
}
/**
* Whether or not the score is needed.
*/
@Override
public boolean needsScores() {
return ((GenericElasticsearchScript) compiledScript.compiled()).uses$_score();
}
};
}
示例2: executable
import org.elasticsearch.script.CompiledScript; //导入方法依赖的package包/类
@Override
public ExecutableScript executable(CompiledScript compiledScript, Map<String, Object> params) {
final String field = (String) compiledScript.compiled();
return new ExecutableScript() {
Map<String, Object> vars = new HashMap<>();
@Override
public void setNextVar(String name, Object value) {
vars.put(name, value);
}
@Override
public Object run() {
Map<String, Object> ctx = (Map<String, Object>) vars.get("ctx");
assertNotNull(ctx);
Map<String, Object> source = (Map<String, Object>) ctx.get("_source");
Number currentValue = (Number) source.get(field);
Number inc = params == null ? 1L : (Number) params.getOrDefault("inc", 1);
source.put(field, currentValue.longValue() + inc.longValue());
return ctx;
}
};
}
示例3: executable
import org.elasticsearch.script.CompiledScript; //导入方法依赖的package包/类
@Override
public ExecutableScript executable(CompiledScript compiledScript, Map<String, Object> params) {
String script = (String) compiledScript.compiled();
for (Entry<String, Object> entry : params.entrySet()) {
script = script.replace("{{" + entry.getKey() + "}}", String.valueOf(entry.getValue()));
}
String result = script;
return new ExecutableScript() {
@Override
public void setNextVar(String name, Object value) {
throw new UnsupportedOperationException("setNextVar not supported");
}
@Override
public Object run() {
return new BytesArray(result);
}
};
}
示例4: search
import org.elasticsearch.script.CompiledScript; //导入方法依赖的package包/类
@Override
public SearchScript search(CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) {
final VectorScoreScript.Factory scriptFactory = (VectorScoreScript.Factory) compiledScript.compiled();
final VectorScoreScript script = (VectorScoreScript) scriptFactory.newScript(vars);
return new SearchScript() {
@Override
public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {
script.setBinaryEmbeddingReader(context.reader().getBinaryDocValues(script.field));
return script;
}
@Override
public boolean needsScores() {
return scriptFactory.needsScores();
}
};
}
开发者ID:lior-k,项目名称:fast-elasticsearch-vector-scoring,代码行数:17,代码来源:VectorScoringScriptEngineService.java
示例5: executable
import org.elasticsearch.script.CompiledScript; //导入方法依赖的package包/类
@Override
public ExecutableScript executable(final CompiledScript compiledScript, final Map<String, Object> vars) {
final Map<String, Object> scriptVars;
if (!contextPropMap.isEmpty()) {
scriptVars = new HashMap<>(contextPropMap);
} else {
scriptVars = new HashMap<>();
}
scriptVars.putAll(vars);
scriptVars.put("threadContext", threadContext);
return new VelocityExecutableScript((VelocityScriptTemplate) compiledScript.compiled(), scriptVars, logger);
}
示例6: executable
import org.elasticsearch.script.CompiledScript; //导入方法依赖的package包/类
@Override
public ExecutableScript executable(CompiledScript compiledScript, @Nullable Map<String, Object> vars) {
VectorScoreScript.Factory scriptFactory = (VectorScoreScript.Factory) compiledScript.compiled();
return scriptFactory.newScript(vars);
}
开发者ID:lior-k,项目名称:fast-elasticsearch-vector-scoring,代码行数:6,代码来源:VectorScoringScriptEngineService.java
示例7: executable
import org.elasticsearch.script.CompiledScript; //导入方法依赖的package包/类
@Override
public ExecutableScript executable(CompiledScript compiledScript, @Nullable Map<String, Object> vars) {
return new RankLibExecutableScript((LtrRanker)compiledScript.compiled());
}
示例8: executable
import org.elasticsearch.script.CompiledScript; //导入方法依赖的package包/类
/**
* Retrieve an {@link ExecutableScript} for later use.
* @param compiledScript A previously compiled script.
* @param vars The variables to be used in the script.
* @return An {@link ExecutableScript} with the currently specified variables.
*/
@Override
public ExecutableScript executable(final CompiledScript compiledScript, final Map<String, Object> vars) {
return new ScriptImpl((GenericElasticsearchScript) compiledScript.compiled(), vars, null);
}