Removing items from the index then re-adding them generally works, except when removing the first item added to the index then re-adding it. In that case, other items (all but the first-added) no longer appear in search results (though count still hints at their existence in the index).
let index = USearchIndex.make(
metric: USearchMetric.l2sq,
dimensions: 1,
connectivity: 8,
quantization: USearchScalar.F32
)
index.reserve(3)
// add 3 entries then ensure all 3 entries are returned
index.add(key: 1, vector: [1.1])
index.add(key: 2, vector: [2.1])
index.add(key: 3, vector: [3.1])
assert(index.count == 3)
assert(index.search(vector: [1.0], count: 3).0 == [1, 2, 3]) // v2.11.7 works 😎
// replace second-added entry then ensure all 3 entries are still returned
index.remove(key: 2)
index.add(key: 2, vector: [2.2])
assert(index.count == 3)
assert(index.search(vector: [1.0], count: 3).0 == [1, 2, 3]) // v2.11.7 works 😎
// replace first-added entry then ensure all 3 entries are still returned
index.remove(key: 1)
index.add(key: 1, vector: [1.2])
let afterReplacingInitial = index.search(vector: [1.0], count: 3).0
assert(index.count == 3)
assert(afterReplacingInitial == [1, 2, 3]) // v2.11.7 fails with "[1] != [1, 2, 3]" 😨
Expected behavior
In the above example the final assertion should succeed, but in fact it fails as the second and third items added to the index no longer appear in search results after the first-added item is replaced.
USearch version
v2.11.7
Operating System
macOS 14.4.1 (building for iOS 17.4)
Hardware architecture
Arm
Which interface are you using?
Other bindings
Are you open to being tagged as a contributor?
[X] I am open to being mentioned in the project .git history as a contributor
Is there an existing issue for this?
[X] I have searched the existing issues
Code of Conduct
[X] I agree to follow this project's Code of Conduct
Describe the bug
Removing items from the index then re-adding them generally works, except when removing the first item added to the index then re-adding it. In that case, other items (all but the first-added) no longer appear in
search
results (thoughcount
still hints at their existence in the index).Steps to reproduce
Here's an adaptation of a Swift test that illustrates the issue
Expected behavior
In the above example the final assertion should succeed, but in fact it fails as the second and third items added to the index no longer appear in
search
results after the first-added item is replaced.USearch version
v2.11.7
Operating System
macOS 14.4.1 (building for iOS 17.4)
Hardware architecture
Arm
Which interface are you using?
Other bindings
Are you open to being tagged as a contributor?
.git
history as a contributorIs there an existing issue for this?
Code of Conduct