Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable milvus pagination query #422

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions lazyllm/tools/rag/milvus_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from lazyllm.common import override, obj2str, str2obj

MILVUS_UPSERT_BATCH_SIZE = 500
MILVUS_PAGINATION_OFFSET = 1000

class MilvusStore(StoreBase):
# we define these variables as members so that pymilvus is not imported until MilvusStore is instantiated.
Expand Down Expand Up @@ -246,8 +247,25 @@ def _gen_field_key(self, k: str) -> str:
def _load_all_nodes_to(self, store: StoreBase) -> None:
uid2node = {}
for group_name in self._client.list_collections():
results = self._client.query(collection_name=group_name,
filter=f'{self._primary_key} != ""')
collection_desc = self._client.describe_collection(collection_name=group_name)
field_names = [field.get("name") for field in collection_desc.get('fields', [])]

iterator = self._client.query_iterator(
collection_name=group_name,
batch_size=MILVUS_PAGINATION_OFFSET,
filter=f'{self._primary_key} != ""',
output_fields=field_names
)

results = []
while True:
result = iterator.next()

if not result:
iterator.close()
break
results += result

for result in results:
node = self._deserialize_node_partial(result)
node._group = group_name
Expand Down
Loading