Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
Other Environment Information
- Hardware parameters: Apple Silicon
- OS type: macOS
- Others: Reproduced on a local
mo-service(SELECT version()=8.0.30-MatrixOne-v1.3.0) at127.0.0.1:6001.pkg/fulltext/fulltext.goandpkg/fulltext/sql.goonorigin/mainat the commit above contain the scanner and SQL generator cited below.
Actual Behavior
Classic fulltext BOOLEAN mode turns double quotes into a phrase only when they wrap the entire search string.
ParsePatternInBooleanMode (pkg/fulltext/fulltext.go) calls ParsePhrase only when strings.HasPrefix(pattern, "\"") && strings.HasSuffix(pattern, "\""). GetOp leaves the '"' arm commented out, so an internal quote is an ordinary character. The boolean scanner then ends the token at the first space inside the quotes.
GenTextSql re-tokenizes each piece in natural-language mode, which treats " as a breaker and drops it. No phrase anchor (pos - N / HAVING COUNT(*)) is generated. MATCH returns success rows that are not the phrase.
Live results on default, ngram, and gojieba (same four rows: matrix database, matrix origin here, origin matrix, database only):
| AGAINST pattern | Actual ids | Expected ids |
|---|---|---|
"matrix origin" |
2 | 2 |
+"matrix origin" |
1, 2, 3 | 2 |
"matrix origin" database |
1, 2, 3, 4 | 1, 2, 4 |
+"matrix origin" +database |
1 | empty |
+"matrix origin" requires the word matrix and treats origin as optional, so every document containing matrix matches. "matrix origin" database becomes a bag-of-words OR, so origin matrix (id 3) matches even though it is not the phrase and does not contain database. +"matrix origin" +database requires matrix AND database and returns matrix database.
The scanner runs before parser-specific logic, so the json parser takes the same split.
Expected Behavior
"" is a documented BOOLEAN operator together with +, -, *, and ~ (CREATE FULLTEXT INDEX). A quoted span is one phrase wherever it sits in the expression:
+"matrix origin"returns only documents that contain the adjacent phrasematrix origin."matrix origin" databasereturns documents that contain that phrase or the worddatabase.+"matrix origin" +databasereturns only documents that contain both the phrase anddatabase.
Whole-string "matrix origin" already does this and is not the bug.
Steps to Reproduce
drop database if exists ft_quote_probe;
create database ft_quote_probe;
use ft_quote_probe;
create table src(id bigint primary key, body varchar(200));
create fulltext index ft on src(body);
insert into src values
(1, 'matrix database'),
(2, 'matrix origin here'),
(3, 'origin matrix'),
(4, 'database only');
select id from src where match(body) against('"matrix origin"' in boolean mode) order by id;
-- 2
select id from src where match(body) against('+"matrix origin"' in boolean mode) order by id;
-- actual: 1, 2, 3 expected: 2
select id from src where match(body) against('"matrix origin" database' in boolean mode) order by id;
-- actual: 1, 2, 3, 4 expected: 1, 2, 4
select id from src where match(body) against('+"matrix origin" +database' in boolean mode) order by id;
-- actual: 1 expected: emptyWITH PARSER ngram and WITH PARSER gojieba produce the same +"matrix origin" result (ids 1, 2, 3). Whole-string "matrix origin" on those parsers still returns only id 2.
The pattern tree for +"matrix origin" is (+ (text "matrix)) (text origin"). SqlBoolean emits a required word = 'matrix' posting and UNIONs the optional origin term. The whole-string pattern "matrix origin" emits word = 'matrix' at pos - 0 UNION word = 'origin' at pos - 7 with HAVING COUNT(*) = 2.
Additional information
Cause is the whole-string guard in ParsePatternInBooleanMode and the commented-out '"' arm in GetOp (pkg/fulltext/fulltext.go). GenTextSql (pkg/fulltext/sql.go) then strips the leftover quote characters, so the posted SQL looks like a normal word search.
This is not #29271. #29271 is the whole-string ParsePhrase path looking up the raw quoted text instead of the index tokenizer. Here the quotes never become a PHRASE node, and the query returns extra rows.
Unquoted +matrix +origin correctly returns ids 2 and 3. That control is not this bug.
Activity
Ariznawlll commentedon Sep 23, 2026
Same scanner, one more successful wrong row. A minus in front of the quotes does not exclude the phrase; it excludes the individual words.
On
MATCH(body) AGAINST('+database -"matrix origin"' IN BOOLEAN MODE)returns only id 4.id 1 contains
databaseand does not contain the phrasematrix origin, so it should be returned. It is dropped because the quotes are not parsed as a phrase: the minus is applied tomatrix, andEvalMinusremoves every document that contains that word.-"matrix origin"alone returns empty. A minus-only boolean query is empty either way, so that statement does not add a separate symptom.cpegeric commentedon Sep 24, 2026
there is no such thing in boolean mode. '"matrix origin" database' does not work. please close it.
Ariznawlll commentedon Sep 27, 2026
测试版本
main5be6cd90b501da225be591ffffe6000bf01f515e原问题验证
按 issue 原始 classic fulltext SQL 在最新 main 上独立执行 3 次,3/3 与研发在 issue comment 中确认的产品契约一致。本结论是设计确认,不表示 classic fulltext 行为被改写。
Happy Path 覆盖
Unhappy Path 覆盖
+"..."、quoted phrase 加普通词及双 required 组合;该语法不作为受支持的 phrase 组合。白盒验证
对照 issue 中研发的 WON'T FIX/按设计说明,并核对 classic fulltext 当前 parser/index 路径;实测结果与说明一致。
回归测试
未加入 MOTR:该行为是 classic fulltext 的已确认设计/限制,研发同时指向 FULLTEXT2 作为正确实现方向;不新增 classic 内部细节的兼容承诺。
测试证据
5be6cd90b501da225be591ffffe6000bf01f515e测试结论
测试通过。