I am using SQLite (3) for a small website. I recently discovered SQLite Full Text Search (FTS) and used it for a simple search function. However, the user inadvertently found that a hyphen ('-') in the search bar does the wrong thing. This seems to indicate that the token following it should be excluded. In fact, when I change the hyphen to plus or space, it works.
My questions are: 1) Am I correct in this analysis? I read the SQLite documentation regarding the FTS function and did not discuss it. 2) How do I mitigate this? Manually replace hyphens before passing them to SQLite?
A small, concrete example of what I see:
sqlite> CREATE VIRTUAL TABLE fts_table USING fts4
...> ( content TEXT );
sqlite> INSERT INTO fts_table VALUES ("Title: F-1 Race (Game Boy)");
sqlite> INSERT INTO fts_table VALUES ("Title: F-Zero (SNES)");
sqlite> INSERT INTO fts_table VALUES ("Title: F-15 Strike Eagle II (Genesis)");
sqlite> SELECT * FROM fts_table;
Title: F-1 Race (Game Boy)
Title: F-Zero (SNES)
Title: F-15 Strike Eagle II (Genesis)
( , .)
, - SELECT MATCH. "f-zero" SQL :
sqlite> SELECT * FROM fts_table WHERE content MATCH 'f-zero';
Title: F-1 Race (Game Boy)
Title: F-15 Strike Eagle II (Genesis)
I.e., "F-Zero". "f + zero" :
sqlite> SELECT * FROM fts_table WHERE content MATCH 'f+zero';
Title: F-Zero (SNES)
, , "+" "-" SQLite, .