Re: Make sqlite3 database searchable on Mac OS X

Jens Alfke <jens-mAcipnqRhZf2eFz/[email protected]>
Newsgroups gmane.comp.db.sqlite.general
Message-ID <[email protected]>

> On Feb 10, 2020, at 8:10 PM, Peng Yu <[email protected]> wrote:
> 
> It seems that sqlite3 databases are not searchable by Spotlight on Mac
> OS X. Is there a way to make them searchable? Thanks.

How would Spotlight know what tables or columns to index? It doesn't understand what database schema mean, and it can't tell a column with user-visible text apart from one with internal info.

You can write a Spotlight indexer plugin for your application that recognizes your file type and scans your SQLite database to generate indexing data.

The downside is that Spotlight is fundamentally file-based: it considers a file to be a single entity. So when the user searches for something that's in your database, it will just show the database file as a hit. It won't show separate results for every row that matches.

(Some apps work around this by creating stub files in a hidden directory, one file per entity. All these files need to contain is a record identifier so your indexer can index the file by looking at the corresponding row in the database. Spotlight will return the stub file as a match; when your app is told to open it, it looks at its record ID and displays the corresponding database row in its UI. Apple Mail is an example; there's a directory somewhere in ~/Library/Mail that contains an empty file for every email message.)

—Jens

PS: Disclaimer: My knowledge of Spotlight is years out of date; it may be that it's advanced since then.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.