使用Spotlight作为“数据库”的应用程序 [英] Using Spotlight as the "database" of an application
问题描述
我正在开发一个OS X应用程序来组织东西(如iTunes是音乐和iPhoto的照片)。而不是有自己的数据库和索引,我正在考虑使用Spotlight基本上用于这个目的。
有没有人试过这个?是明智吗?
我看到的主要好处是简单,避免冗余。当OS X带有一个内置的时候,实现我自己的索引机械似乎有点浪费。
但是我没有使用Spotlight的经验。从用户的角度来看,我知道它在OS X的旧版本中速度很慢和不精确。我也有一种直觉,因为它的目的是搜索整个文件系统,使用它为本地的目的变成了hackish。 / p>
显然,我的应用程序的索引需要不断更新。
多个应用程式可以使用这种方式。我相信至少有一家公司将所有客户数据放入文本文件以使用Spotlight查找信息。我保存了关键字的所有注释,充满信心,Spotlight将能够在以后找到它!
一般来说,你不需要引起Spotlight保持索引更新。这是非常好的观看文件更改和快速索引。
关键,真的,是找出你的文件格式。如果你使用Spotlight可以索引的东西,例如文本文件,那么你不必写入导入器。如果没有,你会。此外,请查看Core Data,因为它具有优秀的 Spotlight支持。
一个警告;有些用户手动关闭特定卷上的Spotlight索引。很少,但可能。
I'm developing an OS X application to organize "things" (as iTunes is to music and iPhoto to photos). Instead of having my own database and index, I'm considering using Spotlight to essentially serve this purpose.
Has anyone tried this? Is it wise?
The main benefit, as I see it, would be simplicity and avoiding redundancy. It seems a bit wasteful to implement my own index machinery when OS X comes with one built in.
I have little experience working with Spotlight, however. From a user's perspective, I do know that it has been slow and imprecise in older versions of OS X. I also have a gut-feeling that since it's aimed at searching the whole filesystem, using it for "local" purposes becomes hackish.
Obviously, my applications's index needs to constantly be up-to-date. Can mdimport
be used for this?
Several apps ship this way. I believe there is at least one company that puts all their customer data into text files to use Spotlight to find information. I save notes with keywords all the time with full confidence that Spotlight will be able to find it later!
In general, you don't need to prod Spotlight to keep the index up to date. It is very good about watching file changes and indexing rapidly.
The key, really, is figuring out your file format. If you go with something that Spotlight can index -- say, text files -- then you don't have to write an importer. If not, you do. Also, have a look at Core Data as it has excellent Spotlight support, too.
One caveat; there are those users that manually turn off spotlight indexing on a particular volume. Rare, but possible.
这篇关于使用Spotlight作为“数据库”的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!