Domanda

I am trying to use FTS3 in sqlite and executing a query which is not returning desired results. here is the query:

select * from table1 where col1 MATCH 'rain';

this query is returning col1 containing text 'strain' too which I do not want. I want the exact replica of this query:

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

any suggestions/comments/help?

È stato utile?

Soluzione 2

In case of FTS3/FTS4 in sqlite database, I conclude that the default tokenizer which is simple (at least) ignores '(' and ')' while tokenizing the elements in any text column. Other special characters can also be checked as I doubt there would be others too. When the match query is executed, these values were ignored. Here is the test case for my scenario:

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');

after executing the following query:

select * from tab1 where val MATCH 'rain';

results were:

this is rain test
this is (rain) test with parenthesis
rain test
this is rain

Altri suggerimenti

I'm unsure why you get this result. You should only get results with matching terms for the MATCH query you posted. Can you post your FTS3 CREATE TABLE statement?

For example:

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top