how do i adopt semantic search with corespotlight?

Generated on 9/25/2024

1 search

To adopt semantic search with Core Spotlight, you can follow these steps as outlined in the session Support semantic search with Core Spotlight:

  1. Donate Searchable Content: Start by donating searchable content to Spotlight that represents what users might want to search for in your app. For example, in a journaling app, each journal entry can be a searchable item.

  2. Indexing: Create a CSSearchableItem by providing a unique identifier, an optional domain identifier, and an attribute set. Ensure your searchable items have the appropriate content type and use system-defined attributes whenever possible.

  3. Semantic Search: Core Spotlight now supports query understanding with SemanticSearch, allowing users to search for content in your app using terms that are similar in meaning, not just exact matches.

  4. Configure Queries: Use CSUserQueryContext to configure queries that best support your user interface needs. You can enable ranked results and configure a suggestions menu in your app.

  5. Boost Ranking: Improve the search experience over time by donating signals that can enhance the ranking of content that users care about most. Engagement and freshness are important signals for adaptive ranking.

  6. Batch Indexing: Use new APIs for efficient donations, including batch indexing with client state and item updates.

For more detailed guidance, you can refer to the session Support semantic search with Core Spotlight at the WWDC 2024.