unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
2.28k stars 143 forks source link

Bug: JAVA Search not match after deleting key #445

Closed tducthang closed 2 months ago

tducthang commented 5 months ago

Describe the bug

When I delete the index and then add it again unorrdered, the search results are incorrect

Steps to reproduce

Index index = new Index.Config().metric("cos").dimensions(2).build();
float[] vec1 = new float[]{0.1f, 0.7f};
float[] vec2 = new float[]{-10.1f, -0.7f};
float[] vec3 = new float[]{5.1f, 7f};
index.add(1, vec1);
index.add(2, vec2);
index.add(3, vec3);
int[] keys = index.search(vec1, 1); // result key=1 is that true

Error: search not match


index.remove(2);
index.remove(1);
index.remove(3);

index.add(1, vec1);
index.add(2, vec2);
index.add(3, vec3);
int[] keys = index.search(vec2, 1); // results keys is 1 ---> Magic in here

And when:

index.remove(1);
index.remove(2);
index.remove(3);

index.add(1, vec1);
index.add(2, vec2);
index.add(3, vec3);
int[] keys = index.search(vec3, 1); // results keys are 1 --> false

Expected behavior

index.search should return the correct key regardless of the deletion order

USearch version

2.8.12

Operating System

Ubuntu 22.04

Hardware architecture

x86

Which interface are you using?

Other bindings

Contact Details

No response

Are you open to being tagged as a contributor?

Is there an existing issue for this?

Code of Conduct

tducthang commented 5 months ago

@ashvardanian Do you have any idea about this? Please check for me, it seems there was a problem when deleting and adding

ashvardanian commented 5 months ago

Hi @tducthang! I believe this issue may have been resolved in subsequent releases of USearch, but assuming Maven releases involve tedious manual steps, we haven't refreshed it. Doing my best to release sooner 🤗

tducthang commented 4 months ago

@ashvardanian Today I tested on C# version 2.12.0 but still encounter this error, please help me check. Thanks