# Running ANN with num\_candidates \> 10000

**URL:** <https://discuss.elastic.co/t/running-ann-with-num-candidates-10000/349387>\
**Category:** Elasticsearch\
**Tags:** vector-search\
**Created:** [December 14, 2023, 4:00pm UTC](https://discuss.elastic.co/t/running-ann-with-num-candidates-10000/349387 "2023-12-14T16:00:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajivhs](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rajivhs](https://discuss.elastic.co/u/rajivhs)\
**Post date:** [December 14, 2023, 4:00pm UTC](https://discuss.elastic.co/t/running-ann-with-num-candidates-10000/349387/1 "2023-12-14T16:00:46Z")

</div>

Hi. Given millions of documents in our index, we would like to run ANN in order to get the top-X documents, where X is greater than 10,000. However, we're running into the `num_candidates cannot exceed 10000` error.

We don't mind making multiple calls if needed to get more than 10k results. I've experimented with using `search_after` together with ANN and `num_candidates=10000` - but this simply returns 0 results after the first 10k.

I know we can replace ANN with a brute-force exact-kNN, but we would prefer to use ANN for the performance benefits if possible.

Is there any way at all to use ANN to get more than 10k results?

---

<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:** [December 14, 2023, 5:02pm UTC](https://discuss.elastic.co/t/running-ann-with-num-candidates-10000/349387/2 "2023-12-14T17:02:36Z")

</div>

@rajivhs

Currently there is not.

Are you wanting to page through many 100s of thousands of nearest neighbors? How big is the data set?

Paging doesn't really work with kNN as your nearest neighbors are exactly that and kNN has no natural filter as part of its retrieval (every doc is a nearest neighbor at some point).

---

<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:** [January 11, 2024, 5:02pm UTC](https://discuss.elastic.co/t/running-ann-with-num-candidates-10000/349387/3 "2024-01-11T17:02:47Z")

</div>

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