SQLITE FTS example does not work

I have downloaded the latest SQLite 3.7.15.2 shell (Win32) and tried to execute one of the FTS exactly as written in http://sqlite.org/fts3.html#section_3 Example

-- Virtual table declaration
CREATE VIRTUAL TABLE docs USING fts3();

-- Virtual table data< br />INSERT INTO docs(docid, content) VALUES(1,'a database is a software system');
INSERT INTO docs(docid, content) VALUES(2,'sqlite is a software system');
INSERT INTO docs(docid, content) VALUES(3,'sqlite is a database');

-- Return the set of documents that contain the term "sqlite", and the< br />-- term "database". This query will return the document with docid 3 only.
SELECT * FROM docs WHERE docs MATCH'sqlite AND database';

But despite the last Commenting on the SELECT resulted in an empty set. Is it a bug in SQLite or an outdated document? (What’s the syntax?).

The most important thing for me is query

SELECT * FROM docs WHERE docs MATCH'(database OR sqlite ) NEAR/5 system';

The kind of query I need does not work in my application. Is there any other way to write it so that it works?

The examples in the documentation use enhanced query syntax.
Check PRAGMA compile_options; include ENABLE_FTS3_PARENTHESIS. < p>

Your NEAR query does not work, it is not a compilation option:

> SELECT * FROM docs WHERE docs MATCH'(database OR sqlite) NEAR/5 system';
Error: malformed MATCH expression: [(database OR sqlite) NEAR/5 system]

The problem is that according to the documentation, NEAR only applies to basic search expressions:< /p>

A NEAR query is specified by putting the keyword “NEAR” between two phrase, term or prefix queries.

Therefore, You must rewrite the search expression accordingly:

> SELECT * FROM docs WHERE docs MATCH'(database NEAR/5 system) OR (sqlite NEAR/5 system)'; 
a database is a software system
sqlite is a software system

I have downloaded the latest SQLite 3.7.15.2 shell (Win32), and Try to execute one of the FTS examples exactly as written in http://sqlite.org/fts3.html#section_3

-- Virtual table declaration
CREATE VIRTUAL TABLE docs USING fts3();

-- Virtual table da ta
INSERT INTO docs(docid, content) VALUES(1,'a database is a software system');
INSERT INTO docs(docid, content) VALUES(2,'sqlite is a software system' );
INSERT INTO docs(docid, content) VALUES(3,'sqlite is a database');

-- Return the set of documents that contain the term "sqlite", and the
-- term "database". This query will return the document with docid 3 only.
SELECT * FROM docs WHERE docs MATCH'sqlite AND database';

But despite The last comment SELECT resulted in an empty set. Is it a bug in SQLite or an outdated document? (What’s the syntax?).

The most important thing for me is query

SELECT * FROM docs WHERE docs MATCH'(database OR sqlite ) NEAR/5 system';

The kind of query I need does not work in my application. Is there any other way to write it so that it works?

The examples in the documentation use enhanced query syntax.
Check PRAGMA compile_options; include ENABLE_FTS3_PARENTHESIS.

Your NEAR The query does not work is not a problem of compilation options:

> SELECT * FROM docs WHERE docs MATCH'(database OR sqlite) NEAR/5 system';
Error: malformed MATCH expression: [(database OR sqlite) NEAR/5 system]

The problem is that, according to the documentation, NEAR only applies to basic search expressions:

A NEAR query is specified by putting the keyword “NEAR” between two phrase, term or prefix queries.

Therefore, you must rewrite the search expression accordingly:

p>

> SELECT * FROM docs WHERE docs MATCH'(database NEAR/5 system) OR (sqlite NEAR/5 system)';
a database is a software system
sqlite is a software system

Leave a Comment

Your email address will not be published.