# ANN Search: ElasticSearch vs FAISS

**URL:** <https://discuss.elastic.co/t/ann-search-elasticsearch-vs-faiss/326653>\
**Category:** Elasticsearch\
**Tags:** vector-search\
**Created:** [February 28, 2023, 6:45am UTC](https://discuss.elastic.co/t/ann-search-elasticsearch-vs-faiss/326653 "2023-02-28T06:45:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![r1ckC139](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/r1ckc139/32/117644_2.png) [@r1ckC139](https://discuss.elastic.co/u/r1ckC139)\
**Post date:** [February 28, 2023, 6:45am UTC](https://discuss.elastic.co/t/ann-search-elasticsearch-vs-faiss/326653/1 "2023-02-28T06:45:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BenTrent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bentrent/32/33915_2.png) [@BenTrent](https://discuss.elastic.co/u/BenTrent)\
**Post date:** [February 28, 2023, 12:43pm UTC](https://discuss.elastic.co/t/ann-search-elasticsearch-vs-faiss/326653/2 "2023-02-28T12:43:17Z")

</div>

There are some improvements you can make to pick up the speed: [Tune approximate kNN search | Elasticsearch Guide [8.6] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-knn-search.html)

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!

---

<div class="post-metadata">

**Author:** ![r1ckC139](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/r1ckc139/32/117644_2.png) [@r1ckC139](https://discuss.elastic.co/u/r1ckC139)\
**Post date:** [February 28, 2023, 3:29pm UTC](https://discuss.elastic.co/t/ann-search-elasticsearch-vs-faiss/326653/3 "2023-02-28T15:29:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 28, 2023, 3:30pm UTC](https://discuss.elastic.co/t/ann-search-elasticsearch-vs-faiss/326653/4 "2023-03-28T15:30:16Z")

</div>

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