How to Limit NSMetadataQuery Search Results

I am performing a searchlight, such as searching using NSMetadataQuery, the problem I am facing is that I cannot restrict NSMetadataQuery from searching for a specific hidden folder, for example / Users / username / Library (since the library is a hidden folder).

Any help would be greatly appreciated.

+4
source share
1 answer

The problem is that the index created by Spotlight is not intended to limit the paths. The index is optimized for quick search of terms, and then you can get the corresponding URL for the result (or other metadata). Index is not optimized for search by path.

The search index (built using SearchKit) is in any case very optimized, and the results are returned very quickly even with a large number of files. Once you get the results, you must filter these results yourself.

Note that most files in ~ / Library will not be included in the index, such as caches, plist files, plugins, etc.

0
source

Source: https://habr.com/ru/post/1437578/


All Articles