0

On Android i would like to use a query similar to this:

SELECT docid FROM docs WHERE docs MATCH '("sqlite database" OR "sqlite library") AND linux'

http://www.sqlite.org/fts3.html#section_3

The problem is that I got a "malformed match expression error". When I do more basic match query it works, and it seems the issue might be because of the parentheses.

When I use exactly the same statement (except the table the column name) the error is the same.

The complete error message:

sqlite returned: error code = 1, msg = statement aborts at 7: 
[SELECT * FROM namedays WHERE names MATCH '("sqlite database" OR "sqlite library") AND linux';]
malformed MATCH expression: [("sqlite database" OR "sqlite library") AND linux], db=/data/data/org.xyz/databases/data

Any idea?

jakk
  • 1,193
  • 2
  • 12
  • 28
  • Please post the exact code (including the query) that is failing, and the exact error message you're getting. – Mat Jul 29 '12 at 11:12
  • Please edit your question to add that information in it. – Mat Jul 29 '12 at 11:29
  • 1
    How are you creating your fts3 table? And further more, how are you constructing the query that turns out malformed? – Jens Jul 29 '12 at 12:31
  • 1
    The table is created by: create virtual table namedays using fts3(_id, names, marked). The query is a simple string passed to SQLiteDatabase.rawQuery() – jakk Jul 29 '12 at 12:52

1 Answers1

4

I believe you do not have SQLite compiled with the SQLITE_ENABLE_FTS3_PARENTHESIS option. As such, you can only use the Standard Query Syntax, not the Enhanced Query Syntax

You can easily verify this by executing the compile_options pragma. For example, we see that my sqlite3 doesn't have the enhanced syntax:

sqlite> PRAGMA compile_options;
DISABLE_DIRSYNC
ENABLE_COLUMN_METADATA
ENABLE_FTS3
ENABLE_RTREE
ENABLE_UNLOCK_NOTIFY
SECURE_DELETE
TEMP_STORE=1
THREADSAFE=1