How is the full text search index maintained?

22 views
Skip to first unread message

Brendan Duddridge

unread,
Jun 6, 2015, 1:32:36 PM6/6/15
to mobile-c...@googlegroups.com
Hi,

If I delete or add a key within a document which is being indexed by the FTS engine, how does that value for that key get removed from the FTS table? And if I update a value in the document, how does it get updated in the FTS engine? Are there triggers that get fired to keep the FTS engine in sync?

Thanks,

Brendan

Jens Alfke

unread,
Jun 6, 2015, 4:37:18 PM6/6/15
to mobile-c...@googlegroups.com

On Jun 6, 2015, at 10:32 AM, Brendan Duddridge <bren...@gmail.com> wrote:

If I delete or add a key within a document which is being indexed by the FTS engine, how does that value for that key get removed from the FTS table? And if I update a value in the document, how does it get updated in the FTS engine? Are there triggers that get fired to keep the FTS engine in sync?

The same way that all view indexes get updated. Whenever you query a view, it re-indexes any documents that have been modified (or created) since the index was last updated. That involves removing any rows that were previously emitted by that document, calling the map function on it, and adding a row for every call to emit().

The only difference with FTS is that the key you provide also gets added to a special table that’s indexed by the SQLite FTS4 indexer.

—Jens

Brendan Duddridge

unread,
Jun 7, 2015, 2:58:08 AM6/7/15
to mobile-c...@googlegroups.com
Ok that's great. Does that also mean that the FTS index does not get synced sync it's just generated locally during any CRUD operations? Would seem to make sense that way to avoid unnecessary sync traffic.

Jens Alfke

unread,
Jun 7, 2015, 3:15:44 AM6/7/15
to mobile-c...@googlegroups.com

On Jun 6, 2015, at 11:58 PM, Brendan Duddridge <bren...@gmail.com> wrote:

Ok that's great. Does that also mean that the FTS index does not get synced sync it's just generated locally during any CRUD operations? Would seem to make sense that way to avoid unnecessary sync traffic.

Yes, totally. Indexes are purely local.

—Jens
Reply all
Reply to author
Forward
0 new messages