Repository navigation
Closed
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
c838d312d7bd2f69c22a9c189d36dfde7a3dc307
Other Environment Information
- Test environment: TKE nightly regression
- Workflow run: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/29723112954
- Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/29723112954/job/88295591946
- Fulltext parser:
gojieba
Actual Behavior
DISTINCT with MATCH works, and ORDER BY with MATCH works, but combining DISTINCT + ORDER BY + MATCH fails:
ERROR 20105 (HY000): not supported: MATCH() AGAINST() function cannot be replaced by FULLTEXT INDEX and full table scan with fulltext search is not supported yet.
This indicates that the optimizer does not rewrite fulltext_match to fulltext_index_scan for this plan shape.
Expected Behavior
The query should use the fulltext index and return author IDs 1 and 2 in order.
Steps to Reproduce
set experimental_fulltext_index = 1;
drop database if exists ft_distinct_order;
create database ft_distinct_order;
use ft_distinct_order;
create table articles (
id int primary key,
title varchar(255),
content text,
author_id int,
fulltext index ft_articles(title, content) with parser gojieba
);
insert into articles values
(1, 'Database Guide', 'database search engine', 1),
(2, 'Vector Guide', 'vector search engine', 2),
(3, 'Transaction Guide', 'database transaction engine', 1),
(4, 'Mixed Guide', 'database vector integration', 2);
-- Works
select distinct author_id from articles
where match(title, content) against('+database' in boolean mode);
-- Fails with ERROR 20105
select distinct author_id from articles
where match(title, content) against('+database' in boolean mode)
order by author_id;Additional information
The fulltext rewrite currently recognizes a limited set of plan shapes. The DISTINCT + ORDER BY plan leaves the scalar MATCH() expression unreplaced.
Add a deterministic regression under test/distributed/cases/fulltext/ when fixed.
Activity
test(plan): cover distinct ordered fulltext match (#25890) (#27779)
Ariznawlll commentedon Sep 1, 2026
测试版本
main@33af6ae3c0c23e4f277137460577ea64678f7ecf原问题验证
同步 gojieba FULLTEXT index 下执行原始
DISTINCT + ORDER BY + MATCH组合,稳定返回author_id=1,2,未再因 ORDER BY 丢失 fulltext index 绑定。Happy Path 覆盖
GROUP BY等价控制返回同一作者集合1,2。2,覆盖排序方向和截断。Unhappy Path 覆盖
白盒验证
不适用。optimizer rewrite 的最终语义可由公开 SQL 结果直接验收。
回归测试
issue_25890_fulltext_distinct_order.test/.result。测试证据
测试结论
测试通过。
test(plan): cover distinct ordered fulltext match (matrixorigin#25890) (
test(plan): cover distinct ordered fulltext match (matrixorigin#25890) (
test(plan): cover distinct ordered fulltext match (matrixorigin#25890) (