Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading data into an index with a different metric silently fails #368

Open
scottbreyfogle opened this issue Mar 7, 2019 · 1 comment
Open

Comments

@scottbreyfogle
Copy link

The title basically says it. If you try to load an index with a different metric, it seems that the system should either try and recover (maybe not possible), or return False/show an error. Instead, it silently creates an empty tree.

Steps to reproduce:

from annoy import AnnoyIndex
PATH = "/tmp/test.ann"

i = AnnoyIndex(2,metric="euclidean")
i.add_item(0,[1,2])
i.build(1) # Returns True
i.save(PATH) # Returns True

i2=AnnoyIndex(2)
i2.load(PATH) # Returns True
assert i.get_n_items() == i2.get_n_items()
@erikbern
Copy link
Collaborator

erikbern commented Mar 8, 2019

there's no foolproof way to catch that the metric isn't right (it's not stored inside the index)

that being said there's a few tricks you can use so maybe we should add those

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants