elasticsearch-java icon indicating copy to clipboard operation
elasticsearch-java copied to clipboard

use gauss function, but request with linear function

Open Honeylemonade opened this issue 2 years ago • 2 comments

Java API client version

8.2.0

Java version

8

Elasticsearch Version

7.17.3

Problem description

image

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

Honeylemonade avatar May 05 '22 03:05 Honeylemonade

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;

ayhankaraa avatar Jan 04 '24 12:01 ayhankaraa

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.

l-trotta avatar Feb 02 '24 16:02 l-trotta