elasticsearch-java
elasticsearch-java copied to clipboard
use gauss function, but request with linear function
Java API client version
8.2.0
Java version
8
Elasticsearch Version
7.17.3
Problem description

I use [logging: level: tracer : TRACE] springboot conf to see the ES request, found that when I send a request with functionScore of gauss, but the request log shows it sended the functionScore of linear as the front pic
It has been a while since this question asked, however if anyone ends up here because of the same problem, as I did, you can try to use the alternative method:
public static FunctionScore gauss(Function<DecayFunction.Builder, ObjectBuilder<DecayFunction>> fn)
this correctly sets the kind:
this._kind = Kind.Gauss;
Thanks for the report, this is probably an issue with the java client code generator, it affects both the gauss
and exp
variants of the functions by setting them as linear
if that specific builder is used. As @ayhankaraa kindly reported, using the alternative version of the builder works because this one isn't affected, for example:
FunctionScore fs = FunctionScoreBuilders.gauss(g -> g
.field("location")
.placement(p -> p
.origin(JsonData.of("something"))));
Once the generator is fixed, the Java client code will be updated to resolve this issue.