Skip to content

Commit

Permalink
add _async support to MilvusClient.search
Browse files Browse the repository at this point in the history
  • Loading branch information
drawnwren committed Nov 21, 2024
1 parent c10d61a commit 45a0038
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pymilvus/milvus_client/milvus_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from pymilvus.orm import utility
from pymilvus.orm.collection import CollectionSchema
from pymilvus.orm.connections import connections
from pymilvus.orm.future import SearchFuture
from pymilvus.orm.types import DataType

from .index import IndexParams
Expand Down Expand Up @@ -366,7 +367,7 @@ def search(
partition_names: Optional[List[str]] = None,
anns_field: Optional[str] = None,
**kwargs,
) -> List[List[dict]]:
) -> List[List[dict]] | SearchFuture:
"""Search for a query vector/vectors.
In order for the search to process, a collection needs to have been either provided
Expand All @@ -388,6 +389,7 @@ def search(
Returns:
List[List[dict]]: A nested list of dicts containing the result data. Embeddings are
not included in the result data.
SearchFuture: If _async is True, return a SearchFuture object.
"""
conn = self._get_connection()
try:
Expand All @@ -408,6 +410,9 @@ def search(
logger.error("Failed to search collection: %s", collection_name)
raise ex from ex

if kwargs.get("_async", False):
return res

ret = []
for hits in res:
query_result = []
Expand Down

0 comments on commit 45a0038

Please sign in to comment.