Skip to content

Commit

Permalink
Fix/add es num_candidates (#9225)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnJyong authored Oct 11, 2024
1 parent d498f4e commit 80b62d5
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import math
from typing import Any, Optional
from urllib.parse import urlparse

Expand Down Expand Up @@ -112,7 +113,8 @@ def delete(self) -> None:

def search_by_vector(self, query_vector: list[float], **kwargs: Any) -> list[Document]:
top_k = kwargs.get("top_k", 10)
knn = {"field": Field.VECTOR.value, "query_vector": query_vector, "k": top_k}
num_candidates = math.ceil(top_k * 1.5)
knn = {"field": Field.VECTOR.value, "query_vector": query_vector, "k": top_k, "num_candidates": num_candidates}

results = self._client.search(index=self._collection_name, knn=knn, size=top_k)

Expand Down

0 comments on commit 80b62d5

Please sign in to comment.