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


Java CompiledScript.compiled方法代码示例

本文整理汇总了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();
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:PainlessScriptEngineService.java

示例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;
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:UpdateIT.java

示例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);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:SuggestSearchIT.java

示例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);
}
 
开发者ID:codelibs,项目名称:elasticsearch-lang-velocity,代码行数:13,代码来源:VelocityScriptEngineService.java

示例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());
}
 
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:5,代码来源:RankLibScriptEngine.java

示例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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:PainlessScriptEngineService.java


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