Reputation: 5598
I want to perform a query in which the WHERE
clausule has the following condition:
MATCH
condition over a column in a FTS3
table
ORMATCH
condition over a column in a non FTS
table.Example:
Say that I have two tables
FTS
table with tags.I want to search all the books that either contain 'Dikjstra' in their content or are tagged with the 'algorithm' word. So I run this query:
SELECT * from books_fts
LEFT OUTER JOIN books_tags ON books_fts.fk_id = books_tags.id
WHERE (books_fts MATCH 'content:%Dijkstra*')
OR (books_tags.tag = 'algorithm')
I think the query is right, and if I run it with either one of the OR
clausules, it works.
However, when running it with the two clausules I get the following error:
unable to use function MATCH in the requested context
Seems to me that I cannot combine a MATCH
with a non MATCH
in the WHERE
clause, even if each of them apply to different tables (one FTS
and another non FTS
).
Is this true? I cannot find information on it.
NOTE: if the causules are separated with AND
instead of OR
the query is valid.
Thanks.
Upvotes: 0
Views: 660
Reputation: 8467
This SQL worked for me
select
*
from
"card"
inner join "note" on "card"."noteId" = "note"."id"
inner join "noteFtsTag" on "noteFtsTag"."rowid" = "note"."rowid"
inner join "cardFtsTag" on "cardFtsTag"."rowid" = "card"."rowid"
where
(
"noteFtsTag"."rowid" in (
select
"rowid"
from
"noteFtsTag"
where
"noteFtsTag"."tags" match ?
)
or "cardFtsTag"."rowid" in (
select
"rowid"
from
"cardFtsTag"
where
"cardFtsTag"."tags" match ?
)
)
Source: https://sqlite.org/forum/forumpost?udc=1&name=1a2f2ffdd80cf795
Upvotes: 0
Reputation: 5598
It seems it's a known issue in SQL:
http://sqlite.1065341.n5.nabble.com/FTS3-bug-with-MATCH-plus-OR-td50714.html
Upvotes: 1