# Not able to get more than 10 results in ANN search using ES 8.5.0 docker image

**URL:** <https://discuss.elastic.co/t/not-able-to-get-more-than-10-results-in-ann-search-using-es-8-5-0-docker-image/318429>\
**Category:** Elasticsearch\
**Tags:** docker, vector-search\
**Created:** [November 8, 2022, 11:34am UTC](https://discuss.elastic.co/t/not-able-to-get-more-than-10-results-in-ann-search-using-es-8-5-0-docker-image/318429 "2022-11-08T11:34:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wole](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wole/32/113085_2.png) [@wole](https://discuss.elastic.co/u/wole)\
**Post date:** [November 8, 2022, 11:34am UTC](https://discuss.elastic.co/t/not-able-to-get-more-than-10-results-in-ann-search-using-es-8-5-0-docker-image/318429/1 "2022-11-08T11:34:59Z")

</div>

Hi team,

I am using the Elasticsearch 8.5.0 docker image (installed and started as explained [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_pull_the_elasticsearch_docker_image)) to do some experimenting with ANN search.  
I followed [this](https://www.elastic.co/guide/en/elasticsearch/reference/8.5/knn-search.html#approximate-knn) guide to perform approximate KNN search and use a POST command similar to the following one to perform a query:

```auto
POST image-index/_search
{
  "knn": {
    "field": "image-vector",
    "query_vector": [-5, 9, -12],
    "k": 10,
    "num_candidates": 100
  },
  "fields": ["title", "file-type"]
}

```

My problem is that the parameter k (number of retrieved vectors) **seems to be limited to 10** : if I decrease it it works well, showing less than 10 results, but as soon as I try to increase it past 10 (for example to 15), it still shows only 10 results.  
Is this a limitation of the docker image or did I skip some important configurations?

Thank you very much

---

<div class="post-metadata">

**Author:** ![Julie\_Tibshirani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julie_tibshirani/32/55628_2.png) [@Julie\_Tibshirani](https://discuss.elastic.co/u/Julie_Tibshirani)\
**Post date:** [November 8, 2022, 3:58pm UTC](https://discuss.elastic.co/t/not-able-to-get-more-than-10-results-in-ann-search-using-es-8-5-0-docker-image/318429/2 "2022-11-08T15:58:04Z")

</div>

Hi @wole , you can think of the 'knn' section as adding 'k' additional matching documents to the search. The default 'size' for the search is still 10, which selects the 10 top-scoring hits. So if you want more than 'k' results returned, you need to adjust the overall 'size' parameter too:

```auto
{
  "knn": {
    "field": "image-vector",
    "query_vector": [-5, 9, -12],
    "k": 50,
    "num_candidates": 100
  },
  "fields": ["title", "file-type"],
  "size": 50
}

```

I realize this is a bit confusing when you're only using kNN-only. But it fits with how the search API works, and is convenient when you're combining both 'knn' and 'query' sections.

---

<div class="post-metadata">

**Author:** ![wole](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wole/32/113085_2.png) [@wole](https://discuss.elastic.co/u/wole)\
**Post date:** [November 9, 2022, 4:34pm UTC](https://discuss.elastic.co/t/not-able-to-get-more-than-10-results-in-ann-search-using-es-8-5-0-docker-image/318429/3 "2022-11-09T16:34:25Z")

</div>

thank you very much, it works now!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 9, 2022, 11:22pm UTC](https://discuss.elastic.co/t/not-able-to-get-more-than-10-results-in-ann-search-using-es-8-5-0-docker-image/318429/4 "2022-11-09T23:22:30Z")

</div>

[Paginate search results | Elasticsearch Guide [8.5] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html) explains it more.

---

<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:** [December 7, 2022, 11:23pm UTC](https://discuss.elastic.co/t/not-able-to-get-more-than-10-results-in-ann-search-using-es-8-5-0-docker-image/318429/5 "2022-12-07T23:23:01Z")

</div>

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