I am using the Elasticsearch 8.5.0 docker image (installed and started as explained here) to do some experimenting with ANN search.
I followed this guide to perform approximate KNN search and use a POST command similar to the following one to perform a query:
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?
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:
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.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.