Depends on what you want to optimize for. See this paper<p><a href="https://arxiv.org/abs/1702.08734" rel="nofollow">https://arxiv.org/abs/1702.08734</a><p>And this library that it describes<p><a href="https://github.com/facebookresearch/faiss">https://github.com/facebookresearch/faiss</a><p>Which is an optimal use of your time as you can install it in a minute with anaconda if you use Python.
In 2D? 3D? <10D? In high-dimensional space?<p>Binary, continuous, or count vectors, or a mix? Or something more novel?<p>What's your distance or similarity method?<p>Is there a bound to your search?<p>Exact or approximate? If approximate, what counts as good enough?<p>All of these affect "optimal".