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

[BUG] KNNQuery serialize precision error

Open luyuncheng opened this issue 11 months ago • 0 comments

What is the bug?

There is a knn query like

KnnQuery origin = new KnnQuery.Builder().field("field").vector(new float[] { 0.1f, 0.4f }).k(1).build();

When it serialize to json string, the result would be:

{"field":{"vector":[0.10000000149011612,0.4000000059604645],"k":1}}

like the test code shows:

https://github.com/opensearch-project/opensearch-java/blob/4436e89a0f48d54e47c2c33689e0b828cbb31149/java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQueryTest.java#L16-L20

Do you have any additional context?

PR #882

luyuncheng avatar Mar 01 '24 07:03 luyuncheng