Typesense Vector Search with Multiple Results Issue
TLDR Henrik had a problem with Typesense vector search returning more results than expected. Kishore Nallan clarified that both k
and per_page
parameters need to be set to 1 to get the desired number of results.
May 02, 2023 (5 months ago)
Henrik
06:17 AMthis might be a noob question and I want to apologize if that question was already answered but I could not find anything that helps me solving my question.
I am currently evaluating Typesense and wanted to try the vector search. I 1:1 implemented the example on the documentation page (https://typesense.org/docs/0.24.1/api/vector-search.html#nearest-neighbor-vector-search) . First thing is, that the documentation seems to be incorrect since the vector field in the schema and search is called "vec" and in the document it is called "location". If I change the "location" field in the document to "vec" it works fine. I added several other documents with different values in the "vec" field.
When I now perform the search I always get all documents returned in the response even if I set k=1 in the vector search. As it is stated in the documentation "k" should determine how many results are returned. So why do I get more results than provided with the "k" parameter? Am I doing anything wrong here? Any help is highly appreciated. 😀
Kishore Nallan
06:20 AMlocation
-- I will fix that!> When I now perform the search I always get all documents returned in the response even if I set k=1 in the vector search.
Do you also pass any pagination parameters?
Kishore Nallan
06:22 AMper_page
and k
parameters, Typesense picks the largest of those 2 values. By default per_page is 10 so you might be getting more than expected number of values.Solution: set both
k
and per_page
to 1.Henrik
12:06 PMMaybe it would be worth noting that in the vector search example as well for anyone else who is wondering... 🙃
Thanks a lot for your help! 🙏
Kishore Nallan
12:07 PMTypesense
Indexed 2779 threads (79% resolved)
Similar Threads
Integrating Semantic Search with Typesense
Krish wants to integrate a semantic search functionality with typesense but struggles with the limitations. Kishore Nallan provides resources, clarifications and workarounds to the raised issues.
Utilizing Vector Search and Word Embeddings for Comprehensive Search in Typesense
Bill sought clarification on using vector search with multiple word embeddings in Typesense and using them instead of OpenAI's embedding. Kishore Nallan and Jason informed him that their development version 0.25 supports open source embedding models. They also resolved Bill's concerns regarding search performance, language support, and limitations in the search parameters.
Moving from Algolia to Typesense: Questions and Answers
Juan sought advice from Kishore Nallan about moving from Algolia to Typesense, handling MultiSearch, setting parameters, checking imported documents, and a specific syntax query.