The issue is that Spotlight APIs appear to be App based & not Document based. Sort of. I think the better way to understand this is that the API was intentionally broadened to cover non-document data, but that shift also makes the API appear more app based. I can't find a way to separate Spotlight data by document. Note the contentURL property of CSSearchableItemAttributeSet, which is how you'd note the document location. So you'll end up creating multiple CSSearchableItems for every document, all of which (for a given document) will have the same content URL. I've tried having each document maintain a UUID as a document-specific identifier and include the identifier in every CSSearchableItem. When performing a query I filter the results with CSUserQueryContext.filterQueries that filter by the document identifier. That works to limit results to the specific file for search operations. My guess here is that this is fairly slow, because you're basically searching everything and then discarding results down
Topic:
App & System Services
SubTopic:
General
Tags: