test_milvus.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. from core.rag.datasource.vdb.milvus.milvus_vector import MilvusConfig, MilvusVector
  2. from tests.integration_tests.vdb.test_vector_store import (
  3. AbstractVectorTest,
  4. get_example_text,
  5. setup_mock_redis,
  6. )
  7. class MilvusVectorTest(AbstractVectorTest):
  8. def __init__(self):
  9. super().__init__()
  10. self.vector = MilvusVector(
  11. collection_name=self.collection_name,
  12. config=MilvusConfig(
  13. uri="http://localhost:19530",
  14. user="root",
  15. password="Milvus",
  16. ),
  17. )
  18. def search_by_full_text(self):
  19. # milvus dos not support full text searching yet in < 2.3.x
  20. hits_by_full_text = self.vector.search_by_full_text(query=get_example_text())
  21. assert len(hits_by_full_text) == 0
  22. def get_ids_by_metadata_field(self):
  23. ids = self.vector.get_ids_by_metadata_field(key="document_id", value=self.example_doc_id)
  24. assert len(ids) == 1
  25. def test_milvus_vector(setup_mock_redis):
  26. MilvusVectorTest().run_all_tests()