FunctionScoreQueryBuilder.add() removed?


I'm trying to implement function_score in Java code. This

is exactly what I'm looking for.
This page also has similar examples:

Problem is, apparently FunctionScoreQueryBuilder.add() has been removed since ElasticSearch 5.x. What should be used instead? Any code examples?

(David Pilato) #2

This may help:


Thanks dadoonet. That's very helpful.

Add more example here that works for me:
For functions
The Java code:
List functionBuilders = new ArrayList<>();
MatchQueryBuilder matchQryBdlr = QueryBuilders.matchQuery("my-data-field", "field-value");
WeightBuilder weightBdlr = ScoreFunctionBuilders.weightFactorFunction(3.0);
functionBuilders.add(new FilterFunctionBuilder(matchQryBdlr, weightBdlr));

GaussDecayFunctionBuilder gaussBuilder = new GaussDecayFunctionBuilder("my-date-field", null, "360d", "90d", 0.5);
functionBuilders.add(new FilterFunctionBuilder(gaussBuilder));

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.