ANN Search: ElasticSearch vs FAISS

As i know, Elasticsearch 8.x support for knn search with hnsw index by default, so i try to compare elasticsearch vs faiss (hnsw index), i set both elasticsearch and faiss with same parameter (m=32, efconstruct=128, efsearch=256, top-k=100), After some experiments, I see that the accuracy when search with elasticsearch and faiss is same, but the search speed with elasticsearch is quite slow compared to faiss (in corpus size: 65k vectors - dim 768, elasticsearch took 0.03 s for 1 query, faiss only took 0.006 s). Is such speed normal when using elasticsearch?

There are some improvements you can make to pick up the speed: Tune approximate kNN search | Elasticsearch Guide [8.6] | Elastic

One of the key ones is force-merging to a single segment. This might take some time (speed improvements on vector segment merging is currently being worked on). But, it will guarantee a single graph being searched, and thus will speed things up some.

But, I don't think we will be as fast as Faiss for a little bit. FAISS takes advantage of CPU hardware acceleration in its vector distance calculations.

Elasticsearch is built on Java, and Java has no such capabilities yet. However, they are on the horizon to be added and as soon as the JDK API is solidified, you can bet we will take advantage ASAP!

1 Like

Hi, @BenTrent
Thank you very much for your quick response, the information you provided is really helpful for me !

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.