opensearch-project / opensearch-project/opensearch-java
[BUG] KNNQuery serialize precision error
Open
Nobody has claimed this yet.
bug
- Dominant language
- Java
- Stars
- 165
- Forks
- 250
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 26
Description
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:
Do you have any additional context?
PR #882
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQueryTest.java at lines 16–20 and reproduce the serialized output shown in the issue. Trace the serialization path exercised by that test and resolve the reported float precision discrepancy, with the test demonstrating the corrected JSON; PR #882 provides additional context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100