nmslib / hnswlib

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

Fix insufficient results during filtering #430

Closed kishorenc closed 1 year ago

kishorenc commented 1 year ago

Very similar in nature to https://github.com/nmslib/hnswlib/pull/344

I've discussed this fix with @dyashuni before and this has been tested on a number of datasets.

dyashuni commented 1 year ago

Thank you, @kishorenc

Idea of the fix: if filter is enabled (!isIdAllowed is false) we don’t care about performance and we should check top_candidates.size() == ef

if filter is disabled (!isIdAllowed is true) we should have the same behaviour as without filter top_candidates.size() == ef || !has_deletions

dyashuni commented 1 year ago

Thank you, @kishorenc