org.elasticsearch.search.lookup.SearchLookup Java Examples

The following examples show how to use org.elasticsearch.search.lookup.SearchLookup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NativeScriptEngineService.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@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();
        }
    };
}
 
Example #2
Source File: VectorScoringScriptEngineService.java    From fast-elasticsearch-vector-scoring with Apache License 2.0 6 votes vote down vote up
@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();
        }
    };
}
 
Example #3
Source File: ScriptGeoSimplify.java    From elasticsearch-plugin-geoshape with MIT License 5 votes vote down vote up
private GeoSearchLeafFactory(
                Map<String, Object> params, SearchLookup lookup) {

            if (params.isEmpty()) {
                throw new IllegalArgumentException("[params] field is mandatory");

            }
            if (!params.containsKey("field")) {
                throw new IllegalArgumentException("Missing mandatory parameter [field]");
            }
            if (!params.containsKey("zoom")) {
                throw new IllegalArgumentException("Missing mandatory parameter [zoom]");
            }
            this.params = params;
            this.lookup = lookup;
            field = params.get("field").toString();
            int zoom = (int) params.get("zoom");
            tolerance = GeoUtils.getToleranceFromZoom(zoom);

            output_format = InternalGeoShape.OutputFormat.GEOJSON;
            if (params.containsKey("output_format")) {
                String string_output_format = params.get("output_format").toString();
                if (string_output_format != null)
                    output_format = InternalGeoShape.OutputFormat.valueOf(string_output_format.toUpperCase(Locale.getDefault()));
            }

            algorithm = GeoShape.Algorithm.DOUGLAS_PEUCKER;
            if (params.containsKey("algorithm")) {
                String algorithm_string = params.get("algorithm").toString();
                if (algorithm_string != null)
                    algorithm = GeoShape.Algorithm.valueOf(algorithm_string.toUpperCase(Locale.getDefault()));
            }

//            geojson_decimals = 20;
            geoJsonWriter = new GeoJsonWriter();
        }
 
Example #4
Source File: ScriptService.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Compiles (or retrieves from cache) and executes the provided search script
 */
public SearchScript search(SearchLookup lookup, Script script, ScriptContext scriptContext, Map<String, String> params) {
    CompiledScript compiledScript = compile(script, scriptContext, SearchContext.current(), params);
    return getScriptEngineServiceForLang(compiledScript.lang()).search(compiledScript, lookup, script.getParams());
}
 
Example #5
Source File: MustacheScriptEngineService.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SearchScript search(CompiledScript compiledScript, SearchLookup lookup,
        @Nullable Map<String, Object> vars) {
    throw new UnsupportedOperationException();
}
 
Example #6
Source File: FilteredSearchContext.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SearchLookup lookup() {
    return in.lookup();
}
 
Example #7
Source File: ScriptQueryParser.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public ScriptQuery(Script script, ScriptService scriptService, SearchLookup searchLookup) {
    this.script = script;
    this.searchScript = scriptService.search(searchLookup, script, ScriptContext.Standard.SEARCH, Collections.<String, String>emptyMap());
}
 
Example #8
Source File: ScriptEngineService.java    From Elasticsearch with Apache License 2.0 votes vote down vote up
SearchScript search(CompiledScript compiledScript, SearchLookup lookup, @Nullable Map<String, Object> vars); 
Example #9
Source File: SearchContext.java    From Elasticsearch with Apache License 2.0 votes vote down vote up
public abstract SearchLookup lookup();