-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
set experimental_fulltext_index=1; | ||
create table src (id bigint primary key, json1 json, json2 json); | ||
insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), | ||
(1, '{"a":2, "b":"中文學習教材"}', '["apple", "orange", "banana", "指引"]'), | ||
(2, '{"a":3, "b":"red blue"}', '{"d":"兒童中文"}'); | ||
create fulltext index ftidx on src (json1) with parser json_value; | ||
select * from src where match(json1) against('red' in boolean mode); | ||
id json1 json2 | ||
0 {"a": 1, "b": "red"} {"d": "happy birthday", "f": "winter"} | ||
select * from src where match(json1) against('中文學習教材' in boolean mode); | ||
id json1 json2 | ||
1 {"a": 2, "b": "中文學習教材"} ["apple", "orange", "banana", "指引"] | ||
create fulltext index ftidx2 on src (json1, json2) with parser json_value; | ||
select * from src where match(json1, json2) against('+red +winter' in boolean mode); | ||
id json1 json2 | ||
0 {"a": 1, "b": "red"} {"d": "happy birthday", "f": "winter"} | ||
select * from src where match(json1, json2) against('中文學習教材' in boolean mode); | ||
id json1 json2 | ||
1 {"a": 2, "b": "中文學習教材"} ["apple", "orange", "banana", "指引"] | ||
drop table src; | ||
create table src (id bigint primary key, json1 text, json2 varchar); | ||
insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), | ||
(1, '{"a":2, "b":"中文學習教材"}', '["apple", "orange", "banana", "指引"]'), | ||
(2, '{"a":3, "b":"red blue"}', '{"d":"兒童中文"}'); | ||
create fulltext index ftidx on src (json1) with parser json_value; | ||
select * from src where match(json1) against('red' in boolean mode); | ||
id json1 json2 | ||
0 {"a":1, "b":"red"} {"d": "happy birthday", "f":"winter"} | ||
select * from src where match(json1) against('中文學習教材' in boolean mode); | ||
id json1 json2 | ||
1 {"a":2, "b":"中文學習教材"} ["apple", "orange", "banana", "指引"] | ||
create fulltext index ftidx2 on src (json1, json2) with parser json_value; | ||
select * from src where match(json1, json2) against('+red +winter' in boolean mode); | ||
id json1 json2 | ||
0 {"a":1, "b":"red"} {"d": "happy birthday", "f":"winter"} | ||
select * from src where match(json1, json2) against('中文學習教材' in boolean mode); | ||
id json1 json2 | ||
1 {"a":2, "b":"中文學習教材"} ["apple", "orange", "banana", "指引"] | ||
drop table src; | ||
create table src (id bigint primary key, json1 json, json2 json, FULLTEXT(json1) with parser json_value); | ||
insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), | ||
(1, '{"a":2, "b":"中文學習教材"}', '["apple", "orange", "banana", "指引"]'), | ||
(2, '{"a":3, "b":"red blue"}', '{"d":"兒童中文"}'); | ||
select * from src where match(json1) against('red' in boolean mode); | ||
id json1 json2 | ||
0 {"a": 1, "b": "red"} {"d": "happy birthday", "f": "winter"} | ||
select * from src where match(json1) against('中文學習教材' in boolean mode); | ||
id json1 json2 | ||
1 {"a": 2, "b": "中文學習教材"} ["apple", "orange", "banana", "指引"] | ||
create fulltext index ftidx2 on src (json1, json2) with parser json_value; | ||
select * from src where match(json1, json2) against('+red +winter' in boolean mode); | ||
id json1 json2 | ||
0 {"a": 1, "b": "red"} {"d": "happy birthday", "f": "winter"} | ||
select * from src where match(json1, json2) against('中文學習教材' in boolean mode); | ||
id json1 json2 | ||
1 {"a": 2, "b": "中文學習教材"} ["apple", "orange", "banana", "指引"] | ||
update src set json1='{"c":"update json"}' where id=0; | ||
drop table src; | ||
create table src (id bigint primary key, json1 text, json2 varchar, fulltext(json1) with parser json_value); | ||
insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), | ||
(1, '{"a":2, "b":"中文學習教材"}', '["apple", "orange", "banana", "指引"]'), | ||
(2, '{"a":3, "b":"red blue"}', '{"d":"兒童中文"}'); | ||
select * from src where match(json1) against('red' in boolean mode); | ||
id json1 json2 | ||
0 {"a":1, "b":"red"} {"d": "happy birthday", "f":"winter"} | ||
select * from src where match(json1) against('中文學習教材' in boolean mode); | ||
id json1 json2 | ||
1 {"a":2, "b":"中文學習教材"} ["apple", "orange", "banana", "指引"] | ||
create fulltext index ftidx2 on src (json1, json2) with parser json_value; | ||
select * from src where match(json1, json2) against('+red +winter' in boolean mode); | ||
id json1 json2 | ||
0 {"a":1, "b":"red"} {"d": "happy birthday", "f":"winter"} | ||
select * from src where match(json1, json2) against('中文學習教材' in boolean mode); | ||
id json1 json2 | ||
1 {"a":2, "b":"中文學習教材"} ["apple", "orange", "banana", "指引"] | ||
update src set json1='{"c":"update_json"}' where id=0; | ||
select * from src where match(json1, json2) against('"update_json"' in boolean mode); | ||
id json1 json2 | ||
0 {"c":"update_json"} {"d": "happy birthday", "f":"winter"} | ||
drop table src; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
-- TODO: run all tests with both experimental_fulltext_index = 0 and 1 | ||
-- TODO: GENERATE the test case to cover all combinations of types (varchar, char and text) | ||
set experimental_fulltext_index=1; | ||
|
||
-- bytejson parser | ||
create table src (id bigint primary key, json1 json, json2 json); | ||
insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), | ||
(1, '{"a":2, "b":"中文學習教材"}', '["apple", "orange", "banana", "指引"]'), | ||
(2, '{"a":3, "b":"red blue"}', '{"d":"兒童中文"}'); | ||
|
||
create fulltext index ftidx on src (json1) with parser json_value; | ||
|
||
select * from src where match(json1) against('red' in boolean mode); | ||
|
||
select * from src where match(json1) against('中文學習教材' in boolean mode); | ||
|
||
create fulltext index ftidx2 on src (json1, json2) with parser json_value; | ||
select * from src where match(json1, json2) against('+red +winter' in boolean mode); | ||
|
||
select * from src where match(json1, json2) against('中文學習教材' in boolean mode); | ||
|
||
drop table src; | ||
|
||
-- bytejson parser | ||
create table src (id bigint primary key, json1 text, json2 varchar); | ||
insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), | ||
(1, '{"a":2, "b":"中文學習教材"}', '["apple", "orange", "banana", "指引"]'), | ||
(2, '{"a":3, "b":"red blue"}', '{"d":"兒童中文"}'); | ||
|
||
create fulltext index ftidx on src (json1) with parser json_value; | ||
|
||
select * from src where match(json1) against('red' in boolean mode); | ||
|
||
select * from src where match(json1) against('中文學習教材' in boolean mode); | ||
|
||
create fulltext index ftidx2 on src (json1, json2) with parser json_value; | ||
select * from src where match(json1, json2) against('+red +winter' in boolean mode); | ||
|
||
select * from src where match(json1, json2) against('中文學習教材' in boolean mode); | ||
|
||
drop table src; | ||
|
||
-- bytejson parser | ||
create table src (id bigint primary key, json1 json, json2 json, FULLTEXT(json1) with parser json_value); | ||
insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), | ||
(1, '{"a":2, "b":"中文學習教材"}', '["apple", "orange", "banana", "指引"]'), | ||
(2, '{"a":3, "b":"red blue"}', '{"d":"兒童中文"}'); | ||
|
||
select * from src where match(json1) against('red' in boolean mode); | ||
|
||
select * from src where match(json1) against('中文學習教材' in boolean mode); | ||
|
||
create fulltext index ftidx2 on src (json1, json2) with parser json_value; | ||
select * from src where match(json1, json2) against('+red +winter' in boolean mode); | ||
|
||
select * from src where match(json1, json2) against('中文學習教材' in boolean mode); | ||
|
||
update src set json1='{"c":"update json"}' where id=0; | ||
|
||
drop table src; | ||
|
||
-- bytejson parser | ||
create table src (id bigint primary key, json1 text, json2 varchar, fulltext(json1) with parser json_value); | ||
insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), | ||
(1, '{"a":2, "b":"中文學習教材"}', '["apple", "orange", "banana", "指引"]'), | ||
(2, '{"a":3, "b":"red blue"}', '{"d":"兒童中文"}'); | ||
|
||
select * from src where match(json1) against('red' in boolean mode); | ||
|
||
select * from src where match(json1) against('中文學習教材' in boolean mode); | ||
|
||
create fulltext index ftidx2 on src (json1, json2) with parser json_value; | ||
select * from src where match(json1, json2) against('+red +winter' in boolean mode); | ||
|
||
select * from src where match(json1, json2) against('中文學習教材' in boolean mode); | ||
|
||
update src set json1='{"c":"update_json"}' where id=0; | ||
|
||
select * from src where match(json1, json2) against('"update_json"' in boolean mode); | ||
|
||
drop table src; |