test_milvus.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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. host='localhost',
  14. port=19530,
  15. user='root',
  16. password='Milvus',
  17. )
  18. )
  19. def search_by_full_text(self):
  20. # milvus dos not support full text searching yet in < 2.3.x
  21. hits_by_full_text = self.vector.search_by_full_text(query=get_example_text())
  22. assert len(hits_by_full_text) == 0
  23. def get_ids_by_metadata_field(self):
  24. ids = self.vector.get_ids_by_metadata_field(key='document_id', value=self.example_doc_id)
  25. assert len(ids) == 1
  26. def test_milvus_vector(setup_mock_redis):
  27. MilvusVectorTest().run_all_tests()