feat: support TiDB Vector full-text and hybrid search (#38112)

Co-authored-by: Crazywoola <100913391+crazywoola@users.noreply.github.com>
Co-authored-by: bkidy <bkidyy.macmini@gmail.com>
This commit is contained in:
Elliot Bai
2026-08-06 07:08:42 +00:00
committed by GitHub
co-authored by Crazywoola bkidy
parent 0277b9eb30
commit cf88aef710
7 changed files with 260 additions and 13 deletions
@@ -29,12 +29,15 @@ from controllers.console.datasets.datasets import (
DatasetRetrievalSettingApi,
DatasetRetrievalSettingMockApi,
DatasetUseCheckApi,
_get_retrieval_methods_by_vector_type,
)
from controllers.console.datasets.error import DatasetInUseError, DatasetNameDuplicateError, IndexingEstimateError
from core.entities.knowledge_entities import IndexingEstimate
from core.errors.error import LLMBadRequestError, ProviderTokenNotInitError
from core.provider_manager import ProviderManager
from core.rag.datasource.vdb.vector_type import VectorType
from core.rag.index_processor.constant.index_type import IndexStructureType
from core.rag.retrieval.retrieval_methods import RetrievalMethod
from extensions.storage.storage_type import StorageType
from models.account import Account, TenantAccountRole
from models.dataset import Dataset, DatasetQuery, Document
@@ -1427,6 +1430,28 @@ class TestDatasetRetrievalSettingApi:
response = method(api)
assert "retrieval_method" in response
def test_tidb_vector_returns_semantic_only_when_fulltext_disabled(self):
with patch(
"controllers.console.datasets.datasets.dify_config.TIDB_VECTOR_ENABLE_FULLTEXT_SEARCH",
False,
):
response = _get_retrieval_methods_by_vector_type(VectorType.TIDB_VECTOR)
assert response["retrieval_method"] == [RetrievalMethod.SEMANTIC_SEARCH.value]
def test_tidb_vector_returns_full_methods_when_fulltext_enabled(self):
with patch(
"controllers.console.datasets.datasets.dify_config.TIDB_VECTOR_ENABLE_FULLTEXT_SEARCH",
True,
):
response = _get_retrieval_methods_by_vector_type(VectorType.TIDB_VECTOR)
assert response["retrieval_method"] == [
RetrievalMethod.SEMANTIC_SEARCH.value,
RetrievalMethod.FULL_TEXT_SEARCH.value,
RetrievalMethod.HYBRID_SEARCH.value,
]
class TestDatasetRetrievalSettingMockApi:
def test_get_success(self, app: Flask):