[PR #25994] Feature integrate alibabacloud mysql vector #31296

Closed
opened 2026-02-21 20:49:11 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/25994

State: closed
Merged: Yes


Summary

With Alibaba Cloud MySQL recently releasing MySQL vector database version, this PR introduces comprehensive support for Alibaba Cloud MySQL Vector Database as a new vector storage option in Dify. The implementation provides native vector search capabilities using RDS MySQL 8.0.36+ with vector extensions, offering both cosine and euclidean distance functions for similarity search.

Type of Change:

  • New feature (non-breaking change which adds functionality)

Changes Made:

  • Added AlibabaCloudMySQLVector class with full vector database operations (create, search, delete)
  • Implemented AlibabaCloudMySQLVectorFactory for vector store initialization
  • Added AlibabaCloud_MYSQL to the VectorType enumeration
  • Created comprehensive configuration system with validation (AlibabaCloudMySQLVectorConfig)
  • Migrated from PyMySQL to mysql-connector-python for better performance and compatibility
  • Set cosine distance as the default similarity function
  • Added support for both vector similarity search and full-text search
  • Implemented proper connection management with context managers
  • Added comprehensive unit tests with 95%+ coverage

Motivation and Context:
This feature enables Dify users to leverage Alibaba Cloud's MySQL vector database capabilities for RAG (Retrieval-Augmented Generation) applications. It provides an alternative to other vector databases with the benefit of using familiar MySQL infrastructure while supporting advanced vector operations.

Dependencies:

  • New Python packages (list them)
    • mysql-connector-python (replaced PyMySQL for better vector support)

Key Features:

  • Vector Storage: Stores embeddings using MySQL's native VECTOR data type
  • Similarity Search: Supports both cosine and euclidean distance functions
  • Full-text Search: MySQL FULLTEXT indexing for hybrid search capabilities
  • Filtering: Document-level filtering by metadata fields
  • Batch Operations: Efficient bulk insert and delete operations

issue link:
Fixes https://github.com/langgenius/dify/issues/26446

Screenshots

Before After
... ...

Checklist

  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/25994 **State:** closed **Merged:** Yes --- ## Summary With Alibaba Cloud MySQL recently releasing MySQL vector database version, this PR introduces comprehensive support for **Alibaba Cloud MySQL Vector Database** as a new vector storage option in Dify. The implementation provides native vector search capabilities using RDS MySQL 8.0.36+ with vector extensions, offering both cosine and euclidean distance functions for similarity search. **Type of Change:** - [x] ✨ New feature (non-breaking change which adds functionality) **Changes Made:** - Added `AlibabaCloudMySQLVector` class with full vector database operations (create, search, delete) - Implemented `AlibabaCloudMySQLVectorFactory` for vector store initialization - Added `AlibabaCloud_MYSQL` to the `VectorType` enumeration - Created comprehensive configuration system with validation (`AlibabaCloudMySQLVectorConfig`) - Migrated from PyMySQL to mysql-connector-python for better performance and compatibility - Set cosine distance as the default similarity function - Added support for both vector similarity search and full-text search - Implemented proper connection management with context managers - Added comprehensive unit tests with 95%+ coverage **Motivation and Context:** This feature enables Dify users to leverage Alibaba Cloud's MySQL vector database capabilities for RAG (Retrieval-Augmented Generation) applications. It provides an alternative to other vector databases with the benefit of using familiar MySQL infrastructure while supporting advanced vector operations. **Dependencies:** - [x] New Python packages (list them) - `mysql-connector-python` (replaced PyMySQL for better vector support) **Key Features:** - **Vector Storage**: Stores embeddings using MySQL's native VECTOR data type - **Similarity Search**: Supports both cosine and euclidean distance functions - **Full-text Search**: MySQL FULLTEXT indexing for hybrid search capabilities - **Filtering**: Document-level filtering by metadata fields - **Batch Operations**: Efficient bulk insert and delete operations **issue link:** Fixes https://github.com/langgenius/dify/issues/26446 ## Screenshots | Before | After | |--------|-------| | ... | ... | ## Checklist - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:49:11 -05:00
yindo closed this issue 2026-02-21 20:49:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31296