I want to change a data point in the index. How can i do that?
import hnswlib
import numpy as np
# Generating sample data
a = np.array([1.0, 0.0, 0.0])
b = np.array([0.0, 1.0, 0.0])
c = np.array([0.0, 0.0, 1.0])
d = np.array([1.0, 1.0, 0.0])
# Declaring index
p = hnswlib.Index(space='l2', dim = 3)
# Initing index - the maximum number of elements should be known beforehand
p.init_index(max_elements = 50, ef_construction = 200, M = 16)
# Element insertion (can be called several times):
p.add_items(a)
p.add_items(b)
p.add_items(c)
labels, distances = p.knn_query(c, k =1)
print labels, distances
#change data points
p.add_items(d, 2)
p.add_items(c, 0)
labels, distances = p.knn_query(d, k =1)
print labels, distances
labels, distances = p.knn_query(c, k =1)
print labels, distances
The query result is not changing after i rewrite the data point label index.
I want to change a data point in the index. How can i do that?
The query result is not changing after i rewrite the data point label index.