Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

Commit 67209b8

Browse files
authored
fix: milvus _get_docs_by_ids (#859)
* fix: fix milvus _get_docs_by_ids Signed-off-by: AnneY <[email protected]> * test: test _get_docs_by_ids with duplicated id Signed-off-by: AnneY <[email protected]> Signed-off-by: AnneY <[email protected]>
1 parent 008007e commit 67209b8

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

docarray/array/storage/milvus/getsetdel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ def _get_docs_by_ids(self, ids: 'Iterable[str]', **kwargs) -> 'DocumentArray':
7474
raise KeyError(f'No documents found for ids {ids}')
7575
docs.extend(self._docs_from_query_response(res))
7676
# sort output docs according to input id sorting
77-
id_to_index = {id_: i for i, id_ in enumerate(ids)}
78-
return DocumentArray(sorted(docs, key=lambda d: id_to_index[d.id]))
77+
return DocumentArray([docs[d] for d in ids])
7978

8079
def _del_docs_by_ids(self, ids: 'Iterable[str]', **kwargs) -> 'DocumentArray':
8180
kwargs = self._update_kwargs_from_config('consistency_level', **kwargs)

tests/unit/array/test_advance_indexing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,13 @@ def test_sequence_str(docs, storage, config, start_storage):
273273
else:
274274
docs = DocumentArray(docs, storage=storage)
275275
# getter
276-
idx = [d.id for d in docs[1, 3, 5, 7, -1, -2]]
276+
idx = [d.id for d in docs[1, 3, 5, 7, -1, -2, 1]]
277277

278278
assert len(docs[idx]) == len(idx)
279279
assert len(docs[tuple(idx)]) == len(idx)
280280

281281
# setter
282+
idx = [d.id for d in docs[1, 3, 5, 7, -1, -2]]
282283
docs[idx] = [Document(text='repl') for _ in range(len(idx))]
283284
idx = [d.id for d in docs[1, 3, 5, 7, -1, -2]]
284285
for _id in idx:

0 commit comments

Comments
 (0)