nmslib / hnswlib

Header-only C++/python library for fast approximate nearest neighbors
https://github.com/nmslib/hnswlib
Apache License 2.0
4.38k stars 647 forks source link

Range Queries #119

Closed cnuernber closed 5 years ago

cnuernber commented 5 years ago

Is it possible to use the graph structure to do range queries assuming the range is some hypercube of all the dimensions?

yurymalkov commented 5 years ago

Hi @cnuernber,

Yes, you can potentially do range queries, but it is not implemented. Range queries are a kind of epsilon-constrained search with a special distance.

IMO it is not too hard to modify the code to support them.

cnuernber commented 5 years ago

Thanks @yurymalkov!

My first read of your response meant to just do a hypersphere query and then a filter step but my second read is to actually build a distance function that returns a very large distance if the point is outside the bounds. I guess then this extends to polytopes if I get one of the two methods above working.

Thank you for your response, it makes sense and I can see a path forward if I need it. Do you mind if I close the issue?

yurymalkov commented 5 years ago

@cnuernber Great! Thanks! Yes, you can close the issue.

tanliboy commented 5 years ago

I am also interested in using the range query and just ran into this. @cnuernber and @yurymalkov, do you have a plan to support it?