CoreSpotlight indexes your app's content into the on-device Spotlight search index so users can find it through search. You describe content as a CSSearchableItem with a CSSearchableItemAttributeSet, then add it to the CSSearchableIndex, where a CSSearchableIndexDelegate keeps the index current and a CSImportExtension or CSIndexExtensionRequestHandler supplies items from an app extension. To search the index, run a CSSearchQuery or CSUserQuery with a context such as CSSearchQueryContext or CSUserQueryContext, returning results and CSSuggestion values and handling failures through CSSearchQueryError and CSIndexError.
Searchable Items 5
Describe a piece of app content and its searchable metadata for indexing in Spotlight.
- ClCSSearchableItemiOS 9.0+An object that represents a single unit of your app's content to index in Spotlight.
- ClCSSearchableItemAttributeSetiOS 9.0+An object that holds the searchable metadata attributes describing a searchable item.
- ClCSPersoniOS 9.0+An object that represents a person associated with a searchable item, such as a sender or contact.
- ClCSLocalizedStringiOS 9.0+A string subclass that provides localized text for searchable item attributes.
- ClCSCustomAttributeKeyiOS 9.0+An object that defines a custom metadata key for storing app-specific searchable attributes.
Managing the Index 4
Add, update, and remove searchable items in the on-device Spotlight index and keep it current.
- ClCSSearchableIndexiOS 9.0+An object that adds, updates, and removes your app's searchable items in the on-device Spotlight index.
- PrCSSearchableIndexDelegateiOS 9.0+A protocol the index uses to request reindexing of items and keep the index current.
- ClCSSearchableIndexDescriptioniOS 27.0+An object that describes the configuration and identity of a searchable index.
- StCSIndexErroriOS 9.0+A structure that describes errors that occur while updating the searchable index.
Index Extensions 5
Supply searchable content from an app extension that the system invokes to populate or import items.
- ClCSImportExtensioniOS 15.0+A class that supplies searchable items to the index from an app extension during content import.
- ClCSIndexExtensionRequestHandleriOS 9.0+A class that handles requests from the system to provide searchable content from an index extension.
- ClUTTypeHierarchyStrategyStrategy for resolving UTTypes by walking the LaunchServices type hierarchy using BFS traversal
- PrUTTypeResolutionStrategyProtocol for pluggable UTType resolution strategies
- StUTTypeResolutionResultResult of a UTType resolution operation with confidence metrics and context
Searching the Index 6
Run queries against the index and configure their behavior with a query context.
- ClCSSearchQueryiOS 10.0+An object that runs a query against the on-device Spotlight index and returns matching searchable items.
- ClCSSearchQueryContextiOS 10.0+An object that configures the behavior and options of a Spotlight search query.
- ClCSUserQueryiOS 16.0+An object that runs a user-facing search query and returns ranked results and suggestions.
- ClCSUserQueryContextiOS 16.0+An object that configures the options and behavior of a user-facing Spotlight search query.
- ClCSSuggestioniOS 16.0+An object that represents a search suggestion returned for a user query.
- StCSSearchQueryErroriOS 10.0+A structure that describes errors that occur while running a search query.
Search Pipeline and Tools 12
Types that model search sources, scored results, and statistics for higher-level search workflows.
- StSpotlightSearchToolA tool you use to make your app’s custom data available to Foundation Models.
- StCoreSpotlightSourceA search source that retrieves data from the app’s Spotlight index.
- StFileSourceA search source that retrieves indexed metadata from files and directories visible to Spotlight.
- StSearchSourceA source of data for Spotlight to search.
- StSearchPipelineDataThe value that flows between pipeline stages, carrying a typed payload.
- EnSearchPipelineDataTypeDeclares the kind of data a pipeline stage accepts or produces.
- StSearchResultsTableTabulated result data — rows with typed columns for display or spreadsheet export.
- StScoredSearchableItemA searchable item paired with a caller-assigned relevance score.
- StSearchableItemAttributeA structure that represents a single metadata attribute of a searchable item.
- StSearchTextResultLLM-generated text summary or analysis from a pipeline stage.
- StSearchCountA scalar count result (e.g., "47 emails from John").
- StSearchStatisticA scalar statistic derived from search results (sum, average, max, min, median, stddev).
Contact Resolution 2
Resolve people referenced in content to known contacts during indexing or search.
- PrContactResolverResolves the current user's identity for search queries involving people.
- StResolvedContactContact information used to match person and organization references in search queries.
Custom Indexing Stages 1
Define custom processing stages that participate in the indexing pipeline.
- PrCustomStageA custom processing stage in a Spotlight search pipeline.