dify/api/providers/vdb/vdb-milvus/tests/integration_tests/test_milvus.py
Asuka Minato f15a8f02ef
ci: add flag for linter (#37018)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-08 04:53:12 +00:00

37 lines
1.1 KiB
Python

from typing import override
from dify_vdb_milvus.milvus_vector import MilvusConfig, MilvusVector
from core.rag.datasource.vdb.vector_integration_test_support import (
AbstractVectorTest,
get_example_text,
)
class MilvusVectorTest(AbstractVectorTest):
def __init__(self):
super().__init__()
self.vector = MilvusVector(
collection_name=self.collection_name,
config=MilvusConfig(
uri="http://localhost:19530",
user="root",
password="Milvus",
),
)
@override
def search_by_full_text(self):
# milvus support BM25 full text search after version 2.5.0-beta
hits_by_full_text = self.vector.search_by_full_text(query=get_example_text())
assert len(hits_by_full_text) >= 0
@override
def get_ids_by_metadata_field(self):
ids = self.vector.get_ids_by_metadata_field(key="document_id", value=self.example_doc_id)
assert len(ids) == 1
def test_milvus_vector(setup_mock_redis):
MilvusVectorTest().run_all_tests()