Saving Hora index to disk?
Closed this issue · 2 comments
Hi,
I'm using Horapy, and everything works great. But how do I save an index to disk after building it, so that I can use it elsewhere or later?
Tried pickling the index but it gives an error that usize objects can't be pickled.
Could be clearer in the docs, but after a little trial and error in my IDE, I think I stumbled across how to do this (I needed the same functionality). Build you index just like you normally would (and as shown in their examples), but after you build()
call dump()
.
index.add(...)
index.add(...)
index.add(...)
index.build('euclidean')
index.dump('path/to/my_index.hora')
Now when you want to reconstitute that in another process, instantiate the index and call load()
with the file from before.
index = HNSWIndex(dimensions, 'usize')
index.load('path/to/my_index.hora')
# It's now ready to search...
index.search(search_vector, 10)
This is a few weeks old so you might have figured this out, but hopefully this will help anyone else who stumbles upon this.
No I hadn't figured it out. Shifted to qdrant, which is nice but a bit much for my requirement. Thanks for this tip. If this works, will go back to Hora.