how can I use core spotlight

Asked on 01/19/2025

1 search

To use Core Spotlight, you can follow the guidance from the session titled "Support semantic search with Core Spotlight" from WWDC 2024. Core Spotlight allows your app to donate searchable content to Spotlight, which is stored in a private, local index on the device. This enables users to search for your app's content directly from Spotlight.

Here are some key steps and features to consider:

  1. Donate Searchable Content: You can donate content to Spotlight by creating a searchable index within your app's sandbox container. If your items reference attachments or web content, consider donating these as separate items with their own content type and attributes.

  2. Semantic Search: Core Spotlight now supports semantic search, allowing users to search for content in your app using terms that are similar in meaning, rather than requiring exact matches. This is enabled by default and can be configured to return ranked results using machine learning models.

  3. Index Delegate Extension: You can set up an index delegate extension to handle reindexing requests from Spotlight. This allows Spotlight to schedule indexing during favorable device conditions, such as when the device is idle.

  4. Ranking and Suggestions: Improve the search experience by donating signals that enhance the ranking of content based on user engagement and freshness. You can configure queries to support a suggestions menu in your app and use engagement signals to improve future search rankings.

For a detailed walkthrough, you can refer to the session Support semantic search with Core Spotlight (01:37) which covers searchable content, and Support semantic search with Core Spotlight (06:56) for results and suggestions.