Bug: fix TiDB Vector full-text search argument order
- Dominant language
- TypeScript
- Stars
- 156k
- Forks
- 24.6k
- Avg merge
- 22h 9m
- Merged PRs (30d)
- 610
Description
### Self Checks
- [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542).
- [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general).
- [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones.
- [x] I confirm that I am using English to submit this report, otherwise it will be closed.
- [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- [x] Please do not modify this template :) and fill in all the required fields.
### Dify version
v1.17.0
### Cloud or Self Hosted
Self Hosted (Docker)
### Steps to reproduce
1. Deploy Dify v1.17.0 with the following configuration:
```env
VECTOR_STORE=tidb_vector
TIDB_VECTOR_ENABLE_FULLTEXT_SEARCH=true
```
2. Use a TiDB Cloud Starter cluster in a supported region.
3. Create a new knowledge base and index a document.
4. Set the retrieval method to **Full-Text Search** or **Hybrid Search**.
5. Run a retrieval query.
Relevant API log:
```text
(pymysql.err.NotSupportedError) (1235,
"This version of TiDB doesn't yet support 'match against a non-constant string'")
FTS_MATCH_WORD(text, %(query)s)
```
### ✔️ Expected Behavior
Full-Text Search and Hybrid Search should execute successfully against TiDB Vector using the multilingual full-text index.
TiDB expects `FTS_MATCH_WORD(query, column)`, so Dify should generate:
```sql
FTS_MATCH_WORD(%(query)s, text)
```
According to the TiDB documentation, the function syntax is
`FTS_MATCH_WORD(query, column)`:
https://docs.pingcap.com/ai/vector-search-full-text-search-sql/
### ❌ Actual Behavior
Full-Text Search and Hybrid Search fail with "match against a non-constant string", while Vector Search works.
Contributor guide
Research direction
Start by locating the TiDB Vector full-text search entry point that emits FTS_MATCH_WORD, using the reported API log and VECTOR_STORE=tidb_vector configuration. Reproduce with TIDB_VECTOR_ENABLE_FULLTEXT_SEARCH=true and a Full-Text or Hybrid Search query, then verify both execute with the query argument before the text column and Vector Search remains working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100