keithwill
keithwill

Reputation: 2044

How do I match on three values / keywords in a full text search?

I am using a query similar to the one below:

SELECT id, description 
FROM FullTextTable
WHERE FullTextTable MATCH '1.010 OR 1.01 OR 1.0100'

If I only use two 'OR' operators, the query returns as expected, but I get no results when I attempt to use three or more 'OR' operators. How would you phrase a query to check for any of three or more values?

This is using the Sqlite FTS4 standard full text query syntax, which I believe does not support changing the order of operations with the use of parenthesis.

I have descriptions which contain decimals values at an arbitrary precision level and our users will not necessarily search at the same precision level as what is stored in the descriptions (e.g. a user may want to search for 1.010, but the description is actually worded as 1.01 or 1.0100 and the user won't know this ahead of time).

Upvotes: 0

Views: 604

Answers (1)

CL.
CL.

Reputation: 180060

With the default tokenizer, periods are not part of words. Your query is the same as

... MATCH '1 010 OR 1 01 OR 1 0100'

Use phrase queries instead:

... MATCH '"1.010" OR "1.01" OR "1.0100"'

Upvotes: 3

Related Questions