Skip to content

Commit

Permalink
feat: [2.4] support recalls field in SearchResult (#2389)
Browse files Browse the repository at this point in the history
milvus issue: milvus-io/milvus#37899

Signed-off-by: chasingegg <[email protected]>
  • Loading branch information
chasingegg authored Dec 2, 2024
1 parent 6f1f8c7 commit c344ab2
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 111 deletions.
7 changes: 4 additions & 3 deletions pymilvus/client/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ def __init__(
):
self._nq = res.num_queries
all_topks = res.topks
self.recalls = res.recalls

self.cost = int(status.extra_info["report_value"] if status and status.extra_info else "0")

Expand Down Expand Up @@ -534,9 +535,9 @@ def __iter__(self) -> SequenceIterator:
def __str__(self) -> str:
"""Only print at most 10 query results"""
reminder = f" ... and {len(self) - 10} results remaining" if len(self) > 10 else ""
if self.cost:
return f"data: {list(map(str, self[:10]))}{reminder}, cost: {self.cost}"
return f"data: {list(map(str, self[:10]))}{reminder}"
recall_msg = f", recalls: {list(map(str, self.recalls))}" if len(self.recalls) > 0 else ""
cost_msg = f", cost: {self.cost}" if self.cost else ""
return f"data: {list(map(str, self[:10]))}{reminder}{recall_msg}{cost_msg}"

__repr__ = __str__

Expand Down
96 changes: 48 additions & 48 deletions pymilvus/grpc_gen/common_pb2.py

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions pymilvus/grpc_gen/common_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class MsgType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
Connect: _ClassVar[MsgType]
ListClientInfos: _ClassVar[MsgType]
AllocTimestamp: _ClassVar[MsgType]
Replicate: _ClassVar[MsgType]
CreateCredential: _ClassVar[MsgType]
GetCredential: _ClassVar[MsgType]
DeleteCredential: _ClassVar[MsgType]
Expand Down Expand Up @@ -515,6 +516,7 @@ DataNodeTt: MsgType
Connect: MsgType
ListClientInfos: MsgType
AllocTimestamp: MsgType
Replicate: MsgType
CreateCredential: MsgType
GetCredential: MsgType
DeleteCredential: MsgType
Expand Down Expand Up @@ -742,12 +744,14 @@ class MsgBase(_message.Message):
def __init__(self, msg_type: _Optional[_Union[MsgType, str]] = ..., msgID: _Optional[int] = ..., timestamp: _Optional[int] = ..., sourceID: _Optional[int] = ..., targetID: _Optional[int] = ..., properties: _Optional[_Mapping[str, str]] = ..., replicateInfo: _Optional[_Union[ReplicateInfo, _Mapping]] = ...) -> None: ...

class ReplicateInfo(_message.Message):
__slots__ = ("isReplicate", "msgTimestamp")
__slots__ = ("isReplicate", "msgTimestamp", "replicateID")
ISREPLICATE_FIELD_NUMBER: _ClassVar[int]
MSGTIMESTAMP_FIELD_NUMBER: _ClassVar[int]
REPLICATEID_FIELD_NUMBER: _ClassVar[int]
isReplicate: bool
msgTimestamp: int
def __init__(self, isReplicate: bool = ..., msgTimestamp: _Optional[int] = ...) -> None: ...
replicateID: str
def __init__(self, isReplicate: bool = ..., msgTimestamp: _Optional[int] = ..., replicateID: _Optional[str] = ...) -> None: ...

class MsgHeader(_message.Message):
__slots__ = ("base",)
Expand Down
8 changes: 5 additions & 3 deletions pymilvus/grpc_gen/msg_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions pymilvus/grpc_gen/msg_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,17 @@ class DataNodeTtMsg(_message.Message):
timestamp: int
segments_stats: _containers.RepeatedCompositeFieldContainer[_common_pb2.SegmentStats]
def __init__(self, base: _Optional[_Union[_common_pb2.MsgBase, _Mapping]] = ..., channel_name: _Optional[str] = ..., timestamp: _Optional[int] = ..., segments_stats: _Optional[_Iterable[_Union[_common_pb2.SegmentStats, _Mapping]]] = ...) -> None: ...

class ReplicateMsg(_message.Message):
__slots__ = ("base", "is_end", "is_cluster", "database", "collection")
BASE_FIELD_NUMBER: _ClassVar[int]
IS_END_FIELD_NUMBER: _ClassVar[int]
IS_CLUSTER_FIELD_NUMBER: _ClassVar[int]
DATABASE_FIELD_NUMBER: _ClassVar[int]
COLLECTION_FIELD_NUMBER: _ClassVar[int]
base: _common_pb2.MsgBase
is_end: bool
is_cluster: bool
database: str
collection: str
def __init__(self, base: _Optional[_Union[_common_pb2.MsgBase, _Mapping]] = ..., is_end: bool = ..., is_cluster: bool = ..., database: _Optional[str] = ..., collection: _Optional[str] = ...) -> None: ...
Loading

0 comments on commit c344ab2

Please sign in to comment.