0

我正在尝试在 sqlite 中使用 FTS3 并执行未返回所需结果的查询。这是查询:

select * from table1 where col1 MATCH 'rain';

此查询返回 col1 也包含我不想要的文本“应变”。我想要这个查询的确切副本:

select * from table1 where col1 like '% rain %';

任何建议/意见/帮助?

4

2 回答 2

0

我不确定你为什么会得到这个结果。您应该只获得与您发布的 MATCH 查询匹配的字词的结果。您可以发布您的 FTS3CREATE TABLE声明吗?

例如:

SQLite version 3.7.11 2012-03-20 11:35:50
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE VIRTUAL TABLE mail USING fts3(subject, body);
sqlite> INSERT INTO mail(docid, subject, body) VALUES(1, 'software feedback', 'found it too slow');
sqlite> INSERT INTO mail(docid, subject, body) VALUES(2, 'software feedback', 'no feedback');
sqlite> INSERT INTO mail(docid, subject, body) VALUES(3, 'slow lunch order',  'was a software problem');
sqlite> select * from mail where body match 'back';
sqlite> select * from mail where body match 'feedback';
software feedback|no feedback
于 2012-09-02T17:44:12.087 回答
0

对于 sqlite 数据库中的 FTS3/FTS4,我得出的结论是,在对任何文本列中的元素进行标记时,简单的(至少)默认标记器会忽略 '(' 和 ')'。也可以检查其他特殊字符,因为我怀疑还会有其他特殊字符。执行匹配查询时,这些值被忽略。这是我的场景的测试用例:

create virtual table tab1 using fts3(val text);
insert into tab1 values('this is rain test');
insert into tab1 values('this is strain test');
insert into tab1 values('this is (rain) test with parenthesis');
insert into tab1 values('rain test');
insert into tab1 values('this is rain');
insert into tab1 values('strain test');
insert into tab1 values('this is strain');

执行以下查询后:

select * from tab1 where val MATCH 'rain';

结果是:

this is rain test
this is (rain) test with parenthesis
rain test
this is rain
于 2012-09-03T09:35:43.497 回答