Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude column from FTS3 table search

Tags:

sqlite

fts3

I have such table:

CREATE VIRTUAL TABLE t USING FTS3(hidden, text1, text2)

I would like user to be able to searh over 'text1' and 'text2' columns, so the query is

SELECT docid FROM t WHERE t MATCH ?

And possible requests are:

SELECT docid FROM t WHERE t MATCH 'foo'
SELECT docid FROM t WHERE t MATCH 'text1:foo OR text2:bar'

Q: how can I exclude 'hidden' column from search, so that user can't find rows by hidden value?

I am going to use 'hidden' column to refer to rows in secondary table with additional information.

like image 853
alex2k8 Avatar asked Oct 12 '10 13:10

alex2k8


1 Answers

Old thread, but if you're using a newer build of SQLite (> 3.8), you can now use the notindexed option, e.g.:

CREATE VIRTUAL TABLE t USING FTS4(uuid, document, notindexed=uuid);

This will exclude the column from match queries.

I've also got this working on iOS by embedding my own build of SQLite 3.8.

Documentation for notindexed option

like image 50
Luke Redpath Avatar answered Nov 15 '22 06:11

Luke Redpath