4

I am performing spotlight like search using NSMetadataQuery, the problem i am facing is that i am not able to restrict NSMetadataQuery from searching the particular hidden folder like /Users/username/Library (as library is hidden folder).

Any help would be appreciated.

Suhaiyl
  • 1,071
  • 9
  • 17

1 Answers1

0

The issue is that the index created by Spotlight is not designed to restrict by paths. The index is optimized to quickly find the terms, and then you can get the corresponding URL for the result (or other metadata). The index is not optimized to search based on the path.

The search index (built using SearchKit) is anyway very much optimized, and results are returned very fast even with large number of files. One you get the results, you have to filter these results yourself.

Note that most files in ~/Library won't be included in the index, like caches, plist files, plugins, etc...

charles
  • 11,212
  • 3
  • 31
  • 46
  • Thankx for the reply, but i am surprised that for me, all the files, be it hidden or library are indexed. you can check the apple sample code "spotlighter". – Suhaiyl Oct 19 '12 at 10:32
  • Maybe the filtering is done by Spotlight itself, then. It was my understanding, that the system would not bother index those files, but maybe they have changed the implementation since Tiger. – charles Oct 30 '12 at 09:44