org.elasticsearch.index.query.functionscore.ScriptScoreFunctionBuilder Java Examples
The following examples show how to use
org.elasticsearch.index.query.functionscore.ScriptScoreFunctionBuilder.
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: ElasticsearchFieldValueScoringStrategy.java From vertexium with Apache License 2.0 | 6 votes |
@Override public QueryBuilder updateElasticsearchQuery( Graph graph, Elasticsearch7SearchIndex searchIndex, QueryBuilder query, QueryParameters queryParameters ) { List<String> fieldNames = getFieldNames(graph, searchIndex, queryParameters, getField()); if (fieldNames == null) { return query; } HashMap<String, Object> scriptParams = new HashMap<>(); scriptParams.put("fieldNames", fieldNames); Script script = new Script(ScriptType.INLINE, "painless", scriptSrc, scriptParams); return QueryBuilders.functionScoreQuery(query, new ScriptScoreFunctionBuilder(script)); }
Example #2
Source File: ElasticsearchHammingDistanceScoringStrategy.java From vertexium with Apache License 2.0 | 6 votes |
@Override public QueryBuilder updateElasticsearchQuery( Graph graph, Elasticsearch7SearchIndex searchIndex, QueryBuilder query, QueryParameters queryParameters ) { List<String> fieldNames = getFieldNames(graph, searchIndex, queryParameters, getField()); if (fieldNames == null) { return query; } HashMap<String, Object> scriptParams = new HashMap<>(); scriptParams.put("hash", getHash()); scriptParams.put("fieldNames", fieldNames); Script script = new Script(ScriptType.INLINE, "painless", scriptSrc, scriptParams); return QueryBuilders.functionScoreQuery(query, new ScriptScoreFunctionBuilder(script)); }
Example #3
Source File: ElasticsearchFieldValueScoringStrategy.java From vertexium with Apache License 2.0 | 6 votes |
@Override public QueryBuilder updateElasticsearchQuery( Graph graph, Elasticsearch5SearchIndex searchIndex, QueryBuilder query, QueryParameters queryParameters ) { List<String> fieldNames = getFieldNames(graph, searchIndex, queryParameters, getField()); if (fieldNames == null) { return query; } HashMap<String, Object> scriptParams = new HashMap<>(); scriptParams.put("fieldNames", fieldNames); Script script = new Script(ScriptType.INLINE, "painless", scriptSrc, scriptParams); return QueryBuilders.functionScoreQuery(query, new ScriptScoreFunctionBuilder(script)); }
Example #4
Source File: ElasticsearchHammingDistanceScoringStrategy.java From vertexium with Apache License 2.0 | 6 votes |
@Override public QueryBuilder updateElasticsearchQuery( Graph graph, Elasticsearch5SearchIndex searchIndex, QueryBuilder query, QueryParameters queryParameters ) { List<String> fieldNames = getFieldNames(graph, searchIndex, queryParameters, getField()); if (fieldNames == null) { return query; } HashMap<String, Object> scriptParams = new HashMap<>(); scriptParams.put("hash", getHash()); scriptParams.put("fieldNames", fieldNames); Script script = new Script(ScriptType.INLINE, "painless", scriptSrc, scriptParams); return QueryBuilders.functionScoreQuery(query, new ScriptScoreFunctionBuilder(script)); }
Example #5
Source File: IndexSearchDaoImpl.java From herd with Apache License 2.0 | 6 votes |
/** * Processes the scripts and score function * * @param queryBuilder the query builder * * @return the function score query builder */ private FunctionScoreQueryBuilder getFunctionScoreQueryBuilder(QueryBuilder queryBuilder, String bdefActiveIndex) { // Script for tag search score multiplier. If bdef set to tag search score multiplier else set to a default value. String inlineScript = "_score * (doc['_index'].value == '" + bdefActiveIndex + "' ? doc['" + BDEF_TAGS_SEARCH_SCORE_MULTIPLIER + "'].value : 1)"; // Set the lang to painless Script script = new Script(ScriptType.INLINE, "painless", inlineScript, Collections.emptyMap()); // Set the script ScriptScoreFunctionBuilder scoreFunction = ScoreFunctionBuilders.scriptFunction(script); // Create function score query builder return new FunctionScoreQueryBuilder(queryBuilder, scoreFunction); }