Integrating databases with Spotlight
Published April 21st, 2006 in General Programming, Cocoa, Mac OS X, SoftwareDue to the way Spotlight is designed, it is very difficult to index monolithic databases, as in all the data stored in one file. Spotlight works by monitoring the file system for modifications, like a file being created or a file being saved. When a file system event occurs, Spotlight identifies the type of file and uses it’s corresponding Spotlight plugin, if available, to extract data from the file. This works great for things like Word documents, text files, and any other kind of document based application.
For applications which use databases, Spotlight indexing is a lot harder to pull off. For example, iCal uses a database to store your calendar events, but iCal is searchable by Spotlight, how can this be? What iCal does is very hackish, for every event in the database it creates a corresponding file in your Library folder which can be indexed by Spotlight.
I think a cleaner option would be for Apple to implement a system service similar to printer spooling. If an application that uses a database updates data, it can post via a notification or some other mechanism to the Spotlight spooler the modified data. When Spotlight is free, it can index the data and add it to it’s repository. Along side the data fed into the Spotlight spooler, there could be some kind of index that Spotlight could pass into the host application when that search result is opened.
What’s also interesting, is that despite the fact that Apple has introduced CoreData to developers, they haven’t provided an easy system for developers to index their databases. Hopefully, a system like the above would help alleviate the problem and eliminate the trickery with files.
Rolex replica 455083b8c823138