filterQueries is actually being passed over and processed on the daemon side
Excellent.
The correct answer is to create a CSImportExtension. That extension point hands you the file you're indexing, side stepping the entire issue.
Looking at the documentation for CSImportExtension it appears that this is for gathering & updating information about a file, not the items in the file. The extension only gets one CSSearchableItemAttributeSet that is for metadata about the file.
An object that provides searchable attributes for file types that the app supports.
Even if I wanted to misuse the API just to trigger a full reindex of the file contents, due to sandbox restrictions I don't think it would be possible to open an arbitrary file. The user would have to select the file in an Open dialog.
My current solution is:
When a document is opened start a Task that gathers all of the uniqueIdentifiers of the searchableItems for this file from the search index (using the contentURL to filter the results).
Gather the model identifiers from SwiftData.
Compare the 2 sets of identifiers. If the sets are not identical then index/delete the appropriate searchableItems (or reindex the whole file).
This isn't the most efficient solution, but the files I'm dealing with likely contain no more than several thousand items.
This leaves me with the outstanding question relating to the CSSearchIndexDelegate.reindex* methods. Should the acknowledgementHandler be called when an error is encountered? The documentation says:
The delegate … must call the acknowledgement handler after all client state information has been saved, so that the indexer can call this method again in case of a crash.
It doesn't describe what to do if the client state couldn't be saved. In my current solution I always call the acknowledgementHandler.