I have a question about Core Spotlight indexing.
I use a method in my main UIViewController
to index data, which works as expected. However, the indexed data stops appearing in Spotlight search some time later (even though the expiry is set to a number of years in the future in most cases).
How should I fix this? I tried making a Spotlight extension (using a copy of the data saved to a shared app Group container), but I don’t know how to check if the extension is working ok or even being called!
I’m just not sure how to get the Spotlight index to persist.
Any help would be greatly appreciated.
So for future reference, I found the error in my code and now that it is fixed, the Spotlight Index behaves as expected. I have not had to use the Spotlight extension.
My indexing method first erased the index before reindexing all data items. It turns out this was not a good way to do it. The index was being erased and then the method must have got interrupted before finishing (maybe by the app being backgrounded). This left the index empty.
Now I index each new data item individually, and delete them individually when they are removed by the user. This works as expected and the index persists. For my particular purpose I did not need a Spotlight extension.