Search code examples
ioscorespotlight

Core Spotlight Index missing over time


I'm trying to understand why my core spotlight indexes eventually don't show up anymore

My strategy is that I index the first time the user opens the app. After successful indexing, I never index again. Everything works great at first, the indexes appear in spotlight. Then over time (I'm unsure of how long, maybe weeks), the indexes stop appearing, even though I made absolutely no changes to them.

So therefore I'm trying to understand how the system handles indexes. Does it rebuild them, thus wiping any previous indexes out? So I would be responsible for re indexing?


Solution

  • On CSSearchableItem, there is a property expirationDate

    The date after which the searchable item should no longer exist.

    Discussion
    If you don’t set the expirationDate property appropriately, the system automatically expires the item after a period of time.

    This should explain why your items disappear after some time.