• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SearchLookup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.search.lookup.SearchLookup的典型用法代码示例。如果您正苦于以下问题:Java SearchLookup类的具体用法?Java SearchLookup怎么用?Java SearchLookup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SearchLookup类属于org.elasticsearch.search.lookup包,在下文中一共展示了SearchLookup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的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: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
@Override
public SearchScript search(CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) {
    final NativeScriptFactory scriptFactory = (NativeScriptFactory) compiledScript.compiled();
    final AbstractSearchScript script = (AbstractSearchScript) scriptFactory.newScript(vars);
    return new SearchScript() {
        @Override
        public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {
            script.setLookup(lookup.getLeafSearchLookup(context));
            return script;
        }
        @Override
        public boolean needsScores() {
            return scriptFactory.needsScores();
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:NativeScriptEngineService.java


示例3: createAggregator

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
protected <A extends Aggregator, B extends AggregationBuilder> A createAggregator(B aggregationBuilder,
                                                                                  IndexSearcher indexSearcher,
                                                                                  MappedFieldType... fieldTypes) throws IOException {
    IndexSettings indexSettings = createIndexSettings();
    SearchContext searchContext = createSearchContext(indexSearcher, indexSettings);
    CircuitBreakerService circuitBreakerService = new NoneCircuitBreakerService();
    when(searchContext.bigArrays()).thenReturn(new MockBigArrays(Settings.EMPTY, circuitBreakerService));
    // TODO: now just needed for top_hits, this will need to be revised for other agg unit tests:
    MapperService mapperService = mapperServiceMock();
    when(mapperService.hasNested()).thenReturn(false);
    when(searchContext.mapperService()).thenReturn(mapperService);
    IndexFieldDataService ifds = new IndexFieldDataService(indexSettings,
            new IndicesFieldDataCache(Settings.EMPTY, new IndexFieldDataCache.Listener() {
            }), circuitBreakerService, mapperService);
    when(searchContext.fieldData()).thenReturn(ifds);

    SearchLookup searchLookup = new SearchLookup(mapperService, ifds, new String[]{"type"});
    when(searchContext.lookup()).thenReturn(searchLookup);

    QueryShardContext queryShardContext = queryShardContextMock(fieldTypes, indexSettings, circuitBreakerService);
    when(searchContext.getQueryShardContext()).thenReturn(queryShardContext);

    @SuppressWarnings("unchecked")
    A aggregator = (A) aggregationBuilder.build(searchContext, null).create(null, true);
    return aggregator;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:AggregatorTestCase.java


示例4: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
@Override
public SearchScript search(CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) {
    final NativeScriptFactory scriptFactory = (NativeScriptFactory) compiledScript.compiled();
    return new SearchScript() {
        @Override
        public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {
            AbstractSearchScript script = (AbstractSearchScript) scriptFactory.newScript(vars);
            script.setLookup(lookup.getLeafSearchLookup(context));
            return script;
        }
        @Override
        public boolean needsScores() {
            return scriptFactory.needsScores();
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:NativeScriptEngineService.java


示例5: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的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


示例6: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的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


示例7: newInstance

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
private static AbstractJavaScript newInstance(Object compiledScript, Map<String, Object> vars, SearchLookup lookup) {
	try {
		Class<?> scriptClass = (Class<?>) compiledScript;
		AbstractJavaScript script = (AbstractJavaScript) scriptClass.newInstance();

		if (vars != null) {
			for (Entry<String, Object> entry : vars.entrySet()) {
				script.setNextVar(entry.getKey(), entry.getValue());
			}
		}

		if (lookup != null) {
			script.setLookup(lookup);
		}

		return script;
	} catch (Exception e) {
		throw new ScriptException("Failed to instantiate script class: " + compiledScript, e);
	}
}
 
开发者ID:btiernay,项目名称:elasticsearch-lang-java,代码行数:21,代码来源:JavaEngineService.java


示例8: setUp

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();
    IndexService index = createIndex("test", Settings.EMPTY, "type", "d", "type=double");
    service = new ExpressionScriptEngineService(Settings.EMPTY);
    lookup = new SearchLookup(index.mapperService(), index.fieldData(), null);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:ExpressionTests.java


示例9: testNeedsScores

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
public void testNeedsScores() {
    IndexService index = createIndex("test", Settings.EMPTY, "type", "d", "type=double");

    PainlessScriptEngineService service = new PainlessScriptEngineService(Settings.EMPTY);
    SearchLookup lookup = new SearchLookup(index.mapperService(), index.fieldData(), null);

    Object compiled = service.compile(null, "1.2", Collections.emptyMap());
    SearchScript ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled),
                                     lookup, Collections.<String, Object>emptyMap());
    assertFalse(ss.needsScores());

    compiled = service.compile(null, "doc['d'].value", Collections.emptyMap());
    ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled),
                        lookup, Collections.<String, Object>emptyMap());
    assertFalse(ss.needsScores());

    compiled = service.compile(null, "1/_score", Collections.emptyMap());
    ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled),
                        lookup, Collections.<String, Object>emptyMap());
    assertTrue(ss.needsScores());

    compiled = service.compile(null, "doc['d'].value * _score", Collections.emptyMap());
    ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled),
                        lookup, Collections.<String, Object>emptyMap());
    assertTrue(ss.needsScores());
    service.close();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:NeedsScoreTests.java


示例10: createSearchScript

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
public SearchScript createSearchScript(Map<String, Object> vars, SearchLookup lookup) {
    Map<String, Object> context = new HashMap<>();
    if (params != null) {
        context.putAll(params);
    }
    if (vars != null) {
        context.putAll(vars);
    }
    return new MockSearchScript(lookup, context, script != null ? script : ctx -> source);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:MockScriptEngine.java


示例11: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
@Override
public SearchScript search(CompiledScript compiledScript, SearchLookup lookup,
        @Nullable Map<String, Object> vars) {
    throw new UnsupportedOperationException();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:MustacheScriptEngineService.java


示例12: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
@Override
public SearchScript search(CompiledScript compiledScript, SearchLookup lookup, @Nullable Map<String, Object> vars) {
    MockCompiledScript compiled = (MockCompiledScript) compiledScript.compiled();
    return compiled.createSearchScript(vars, lookup);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:MockScriptEngine.java


示例13: MockSearchScript

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
public MockSearchScript(SearchLookup lookup, Map<String, Object> vars, Function<Map<String, Object>, Object> script) {
    this.lookup = lookup;
    this.vars = vars;
    this.script = script;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:MockScriptEngine.java


示例14: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
/**
 * Compiles (or retrieves from cache) and executes the provided search script
 */
public SearchScript search(SearchLookup lookup, Script script, ScriptContext scriptContext) {
    CompiledScript compiledScript = compile(script, scriptContext);
    return search(lookup, compiledScript, script.getParams());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:ScriptService.java


示例15: lookup

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
@Override
public SearchLookup lookup() {
    return in.lookup();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:FilteredSearchContext.java


示例16: lookup

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
public SearchLookup lookup() {
    return getQueryShardContext().lookup();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:SearchContext.java


示例17: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
@Override
public SearchScript search(CompiledScript compiledScript, SearchLookup lookup, @Nullable Map<String, Object> vars) {
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ScriptServiceTests.java


示例18: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
@Override
public SearchScript search(CompiledScript compiledScript, SearchLookup lookup, Map<String, Object> vars) {
    throw new UnsupportedOperationException();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:UpdateIT.java


示例19: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的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


示例20: search

import org.elasticsearch.search.lookup.SearchLookup; //导入依赖的package包/类
@Override
public SearchScript search(CompiledScript compiledScript, SearchLookup lookup, Map<String, Object> vars) {
    throw new UnsupportedOperationException("search script not supported");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:SuggestSearchIT.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IDataSet类代码示例发布时间:2022-05-22
下一篇:
Java BlockWheat类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap