Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-pk
Browse files Browse the repository at this point in the history
aunjgr committed Jan 16, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 6a2f5cd + 5d63c0d commit ebd4f04
Showing 4 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/fulltext/fulltext.go
Original file line number Diff line number Diff line change
@@ -826,6 +826,10 @@ func ParsePatternInNLMode(pattern string) ([]*Pattern, error) {
}
}

if len(list) == 0 {
return nil, moerr.NewInternalErrorNoCtx("Invalid input search string. search string onverted to empty pattern")
}

// assign index
idx := int32(0)
for _, p := range list {
17 changes: 17 additions & 0 deletions pkg/fulltext/fulltext_test.go
Original file line number Diff line number Diff line change
@@ -195,6 +195,23 @@ func TestPatternFail(t *testing.T) {
}
}

func TestPatternNLFail(t *testing.T) {

tests := []TestCase{
{
pattern: "+[[[",
},
{
pattern: "+''",
},
}

for _, c := range tests {
_, err := PatternToString(c.pattern, int64(tree.FULLTEXT_NL))
require.NotNil(t, err)
}
}

func TestFullTextNL(t *testing.T) {

pattern := "apple banana"
4 changes: 4 additions & 0 deletions test/distributed/cases/fulltext/fulltext.result
Original file line number Diff line number Diff line change
@@ -11,6 +11,10 @@ insert into src values (0, 'color is red', 't1'), (1, 'car is yellow', 'crazy ca
create fulltext index ftidx on src (body, title);
select * from src where match(body) against('red');
not supported: MATCH() AGAINST() function cannot be replaced by FULLTEXT INDEX and full table scan with fulltext search is not supported yet.
select * from src where match(body,title) against('+]]]');
internal error: Invalid input search string. search string onverted to empty pattern
select * from src where match(body,title) against('+I'm');
SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 55 near "m');";
select match(body) against('red') from src;
not supported: MATCH() AGAINST() function cannot be replaced by FULLTEXT INDEX and full table scan with fulltext search is not supported yet.
alter table src add fulltext index ftidx2 (body);
2 changes: 2 additions & 0 deletions test/distributed/cases/fulltext/fulltext.sql
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ create fulltext index ftidx on src (body, title);

-- check fulltext_match with index error
select * from src where match(body) against('red');
select * from src where match(body,title) against('+]]]');
select * from src where match(body,title) against('+I'm');
select match(body) against('red') from src;

0 comments on commit ebd4f04

Please sign in to comment.