Core Spotlight: Best practice for deleting searchable items

I've implemented Core Spotlight indexing of the Core Data in my macOS app, using NSCoreDataCoreSpotlightDelegate, and it seems to be working.

Any new or changed Core Data objects and attributes seem to be added to the index automatically and immediately, but searchable items for deleted objects won't be automatically removed. I guess this is working as expected?

I've implemented the willSave: method in the relevant NSManagedObject subclasses, where I check the deleted property and run deleteSearchableItemsWithIdentifiers on the default Searchable Index.

I also delete searchable items for deleted Core Data objects in my QuickLook extension's preparePreviewOfSearchableItemWithIdentifier method.

I suppose what I'm asking is: Am I understanding this right and is this the best way to do it?

Core Spotlight: Best practice for deleting searchable items
 
 
Q