當前位置: 首頁>>代碼示例>>Java>>正文


Java LeafSearchLookup類代碼示例

本文整理匯總了Java中org.elasticsearch.search.lookup.LeafSearchLookup的典型用法代碼示例。如果您正苦於以下問題:Java LeafSearchLookup類的具體用法?Java LeafSearchLookup怎麽用?Java LeafSearchLookup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LeafSearchLookup類屬於org.elasticsearch.search.lookup包,在下文中一共展示了LeafSearchLookup類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ScriptImpl

import org.elasticsearch.search.lookup.LeafSearchLookup; //導入依賴的package包/類
/**
 * Creates a ScriptImpl for the a previously compiled Painless script.
 * @param script The previously compiled Painless script.
 * @param vars The initial variables to run the script with.
 * @param lookup The lookup to allow search fields to be available if this is run as a search script.
 */
ScriptImpl(final GenericElasticsearchScript script, final Map<String, Object> vars, final LeafSearchLookup lookup) {
    this.script = script;
    this.lookup = lookup;
    this.variables = new HashMap<>();

    if (vars != null) {
        variables.putAll(vars);
    }

    if (lookup != null) {
        variables.putAll(lookup.asMap());
        doc = lookup.doc();
    } else {
        doc = null;
    }

    scoreLookup = script.uses$_score() ? ScriptImpl::getScore : scorer -> 0.0;
    ctxLookup = script.uses$ctx() ? variables -> (Map<?, ?>) variables.get("ctx") : variables -> null;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:26,代碼來源:ScriptImpl.java

示例2: initialize

import org.elasticsearch.search.lookup.LeafSearchLookup; //導入依賴的package包/類
public void initialize(Engine.Searcher docSearcher, ParsedDocument parsedDocument) {
    this.docSearcher = docSearcher;

    IndexReader indexReader = docSearcher.reader();
    LeafReaderContext atomicReaderContext = indexReader.leaves().get(0);
    LeafSearchLookup leafLookup = lookup().getLeafSearchLookup(atomicReaderContext);
    leafLookup.setDocument(0);
    leafLookup.source().setSource(parsedDocument.source());

    Map<String, SearchHitField> fields = new HashMap<>();
    for (IndexableField field : parsedDocument.rootDoc().getFields()) {
        fields.put(field.name(), new InternalSearchHitField(field.name(), Collections.emptyList()));
    }
    hitContext().reset(
            new InternalSearchHit(0, "unknown", new Text(parsedDocument.type()), fields),
            atomicReaderContext, 0, docSearcher.searcher()
    );
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:19,代碼來源:PercolateContext.java

示例3: search

import org.elasticsearch.search.lookup.LeafSearchLookup; //導入依賴的package包/類
@SuppressWarnings({"unchecked"})
@Override
public SearchScript search(final CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) {
    return new SearchScript() {

        @Override
        public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {
            final LeafSearchLookup leafLookup = lookup.getLeafSearchLookup(context);
            boolean debug = true;
            if (vars != null && vars.containsKey("debug")) {
                debug = (Boolean)vars.get("debug");
            }
            return ((Factory) compiledScript.compiled()).newScript(leafLookup, debug);
        }

        @Override
        public boolean needsScores() {
            // TODO: can we reliably know if a vectorizer script does not make use of _score
            return false;
        }
    };
}
 
開發者ID:brwe,項目名稱:es-token-plugin,代碼行數:23,代碼來源:PMMLModelScriptEngineService.java

示例4: PMMLModel

import org.elasticsearch.search.lookup.LeafSearchLookup; //導入依賴的package包/類
private PMMLModel(ModelInputEvaluator<Input> features, EsModelEvaluator<Input, Output> model,
                  LeafSearchLookup lookup, boolean debug) {
    this.dataSource = new EsDataSource() {
        @Override
        protected LeafDocLookup getDocLookup() {
            return lookup.doc();
        }

        @Override
        protected LeafIndexLookup getLeafIndexLookup() {
            return lookup.indexLookup();
        }
    };
    this.lookup = lookup;
    this.features = features;
    this.model = model;
    this.debug = debug;
}
 
開發者ID:brwe,項目名稱:es-token-plugin,代碼行數:19,代碼來源:PMMLModelScriptEngineService.java

示例5: getLeafSearchScript

import org.elasticsearch.search.lookup.LeafSearchLookup; //導入依賴的package包/類
@Override
public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {
    LeafSearchLookup leafLookup = lookup.getLeafSearchLookup(context);

    Map<String, Object> ctx = new HashMap<>();
    ctx.putAll(leafLookup.asMap());
    if (vars != null) {
        ctx.putAll(vars);
    }

    AbstractSearchScript leafSearchScript = new AbstractSearchScript() {

        @Override
        public Object run() {
            return script.apply(ctx);
        }

        @Override
        public void setNextVar(String name, Object value) {
            ctx.put(name, value);
        }

        @Override
        public void setScorer(Scorer scorer) {
            super.setScorer(scorer);
            ctx.put("_score", new ScoreAccessor(scorer));
        }
    };
    leafSearchScript.setLookup(leafLookup);
    return leafSearchScript;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:32,代碼來源:MockScriptEngine.java

示例6: setLookup

import org.elasticsearch.search.lookup.LeafSearchLookup; //導入依賴的package包/類
void setLookup(LeafSearchLookup lookup) {
    this.lookup = lookup;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:4,代碼來源:AbstractSearchScript.java

示例7: search

import org.elasticsearch.search.lookup.LeafSearchLookup; //導入依賴的package包/類
@Override
public SearchScript search(CompiledScript compiledScript, SearchLookup lookup, Map<String, Object> vars) {
    final long inc;
    if (vars == null || vars.containsKey("inc") == false) {
        inc = 0;
    } else {
        inc = ((Number) vars.get("inc")).longValue();
    }
    return new SearchScript() {

        private Map<String, Object> vars = new HashMap<>(2);

        @Override
        public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {

            final LeafSearchLookup leafLookup = lookup.getLeafSearchLookup(context);

            return new LeafSearchScript() {
                @Override
                public void setNextVar(String name, Object value) {
                    vars.put(name, value);
                }

                @Override
                public Object run() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public void setScorer(Scorer scorer) {
                }

                @Override
                public void setSource(Map<String, Object> source) {
                }

                @Override
                public void setDocument(int doc) {
                    if (leafLookup != null) {
                        leafLookup.setDocument(doc);
                    }
                }

                @Override
                public long runAsLong() {
                    return ((Number) vars.get("_value")).longValue() + inc;
                }

                @Override
                public double runAsDouble() {
                    return ((Number) vars.get("_value")).doubleValue() + inc;
                }
            };
        }

        @Override
        public boolean needsScores() {
            return false;
        }
    };
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:62,代碼來源:AvgIT.java

示例8: newScript

import org.elasticsearch.search.lookup.LeafSearchLookup; //導入依賴的package包/類
public PMMLModel<Input, Output> newScript(LeafSearchLookup lookup, boolean debug) {
    return new PMMLModel<>(features, model, lookup, debug);
}
 
開發者ID:brwe,項目名稱:es-token-plugin,代碼行數:4,代碼來源:PMMLModelScriptEngineService.java


注:本文中的org.elasticsearch.search.lookup.LeafSearchLookup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。