elastic icon indicating copy to clipboard operation
elastic copied to clipboard

Add test for score of Infinity

Open olivere opened this issue 5 years ago • 1 comments

Some queries might return a score of Infinity, as noted in this conversation in #1377:

@olivere When use pinned query, sometimes score will be "Infinity" (wrapped it in function score query), but with definition of *float64 in SearchHit.Score(search.go), there will be an UnmashalError. json: cannot unmarshal string into Go struct field SearchHit._score of type float64 I wanna have a pull request but I think this change will break some of the users' codes (maybe they export the score data and define it as float64 too), so I think I should just report this, and leave it to your decision.

I think it is a common problem of many query type, Java support NaN and Infinity, and the server side of elasticsearch will sometimes return this 2 cases, for example, wrong math calculation for NaN, geo for Infinity, and this will result in UnmarshalError of the golang Client SearchHit type.

We need to add a test for this and see what we can do to work around these issues.

olivere avatar Aug 31 '20 08:08 olivere

Fixing this is probably a breaking change. Moving to 8.x.

olivere avatar Sep 22 '21 11:09 olivere