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


Java SearchLookup类代码示例

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


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


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