Repository navigation
BUG FIX: Fulltext skip overlap from N-gram output 2.1-dev - #21799
Merged
mergify[bot] merged 2 commits intoMay 8, 2025
Merged
Conversation
fengttt
approved these changes
May 7, 2025
XuPeng-SH
approved these changes
May 8, 2025
ghost
approved these changes
May 8, 2025
volgariver6
pushed a commit
to volgariver6/matrixone
that referenced
this pull request
May 14, 2025
…in#21799) 3-gram output is usually overlap each other. Overlap is essential for building index but it is not necessary and also introduce super complicated SQL. For query, remove the unnecessary overlap from N-gram output is a must. e.g. The query should not have any overlap. { pattern: "肥胖的原因都是因为摄入脂肪多导致的吗", expect: "(text 0 0 肥胖的) (text 1 9 原因都) (text 2 18 是因为) (text 3 27 摄入脂) (text 4 36 肪多导) (text 5 45 致的吗)", }, We also need to remove the overlap intelligently. e.g. "读写汉字" With N-gram, we will have tokens "读写汉", "写汉字", "汉字, "字". Simple way is to look for overlap sequentially and remove the overlap. The result will be "读写汉" and "字". However, "字" is a single character which require prefix_eq("字") in SQL. The optimal tokens should be longest token, such as "读写汉", "写汉字" as a result. In boolean mode, we change WITH t00 AS ( SELECT doc_id FROM _mo_index_secondaryWHERE word = '读书会') to WITH t00 AS ( SELECT doc_id FROM _mo_index_secondaryWHERE word = '读书会' GROUP BY doc_id) and t01, t02 as well, adding the group by. Then t0 will have only 1 row. Approved by: @fengttt, @XuPeng-SH, @heni02
aressu1985
pushed a commit
that referenced
this pull request
May 14, 2025
…21844) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #21678 #21774 ## What this PR does / why we need it: 3-gram output is usually overlap each other. Overlap is essential for building index but it is not necessary and also introduce super complicated SQL. For query, remove the unnecessary overlap from N-gram output is a must. e.g. The query should not have any overlap. { pattern: "肥胖的原因都是因为摄入脂肪多导致的吗", expect: "(text 0 0 肥胖的) (text 1 9 原因都) (text 2 18 是因为) (text 3 27 摄入脂) (text 4 36 肪多导) (text 5 45 致的吗)", }, We also need to remove the overlap intelligently. e.g. "读写汉字" With N-gram, we will have tokens "读写汉", "写汉字", "汉字, "字". Simple way is to look for overlap sequentially and remove the overlap. The result will be "读写汉" and "字". However, "字" is a single character which require prefix_eq("字") in SQL. The optimal tokens should be longest token, such as "读写汉", "写汉字" as a result. In boolean mode, we change WITH t00 AS ( SELECT doc_id FROM _mo_index_secondaryWHERE word = '读书会') to WITH t00 AS ( SELECT doc_id FROM _mo_index_secondaryWHERE word = '读书会' GROUP BY doc_id) and t01, t02 as well, adding the group by. Then t0 will have only 1 row. Co-authored-by: Eric Lam <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #21678 #21774
What this PR does / why we need it:
3-gram output is usually overlap each other. Overlap is essential for building index but it is not necessary and also introduce super complicated SQL. For query, remove the unnecessary overlap from N-gram output is a must.
e.g.
The query should not have any overlap.
{
pattern: "肥胖的原因都是因为摄入脂肪多导致的吗",
expect: "(text 0 0 肥胖的) (text 1 9 原因都) (text 2 18 是因为) (text 3 27 摄入脂) (text 4 36 肪多导) (text 5 45 致的吗)",
},
We also need to remove the overlap intelligently.
e.g. "读写汉字"
With N-gram, we will have tokens "读写汉", "写汉字", "汉字, "字".
Simple way is to look for overlap sequentially and remove the overlap. The result will be "读写汉" and "字".
However, "字" is a single character which require prefix_eq("字") in SQL.
The optimal tokens should be longest token, such as "读写汉", "写汉字" as a result.
In boolean mode,
we change
WITH t00 AS ( SELECT doc_id FROM _mo_index_secondaryWHERE word = '读书会')
to
WITH t00 AS ( SELECT doc_id FROM _mo_index_secondaryWHERE word = '读书会' GROUP BY doc_id)
and t01, t02 as well, adding the group by. Then t0 will have only 1 row.