TechnologiesData, Storage & Cloud

CoreSpotlight

iOSmacOStvOSwatchOSvisionOS

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.

  • Cl
    CSSearchableItemiOS 9.0+
    An object that represents a single unit of your app's content to index in Spotlight.
  • Cl
    CSSearchableItemAttributeSetiOS 9.0+
    An object that holds the searchable metadata attributes describing a searchable item.
  • Cl
    CSPersoniOS 9.0+
    An object that represents a person associated with a searchable item, such as a sender or contact.
  • Cl
    CSLocalizedStringiOS 9.0+
    A string subclass that provides localized text for searchable item attributes.
  • Cl
    CSCustomAttributeKeyiOS 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.

  • Cl
    CSSearchableIndexiOS 9.0+
    An object that adds, updates, and removes your app's searchable items in the on-device Spotlight index.
  • Pr
    CSSearchableIndexDelegateiOS 9.0+
    A protocol the index uses to request reindexing of items and keep the index current.
  • Cl
    CSSearchableIndexDescriptioniOS 27.0+
    An object that describes the configuration and identity of a searchable index.
  • St
    CSIndexErroriOS 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.

  • Cl
    CSImportExtensioniOS 15.0+
    A class that supplies searchable items to the index from an app extension during content import.
  • Cl
    CSIndexExtensionRequestHandleriOS 9.0+
    A class that handles requests from the system to provide searchable content from an index extension.
  • Cl
    UTTypeHierarchyStrategy
    Strategy for resolving UTTypes by walking the LaunchServices type hierarchy using BFS traversal
  • Pr
    UTTypeResolutionStrategy
    Protocol for pluggable UTType resolution strategies
  • St
    UTTypeResolutionResult
    Result 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.

  • Cl
    CSSearchQueryiOS 10.0+
    An object that runs a query against the on-device Spotlight index and returns matching searchable items.
  • Cl
    CSSearchQueryContextiOS 10.0+
    An object that configures the behavior and options of a Spotlight search query.
  • Cl
    CSUserQueryiOS 16.0+
    An object that runs a user-facing search query and returns ranked results and suggestions.
  • Cl
    CSUserQueryContextiOS 16.0+
    An object that configures the options and behavior of a user-facing Spotlight search query.
  • Cl
    CSSuggestioniOS 16.0+
    An object that represents a search suggestion returned for a user query.
  • St
    CSSearchQueryErroriOS 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.

  • St
    SpotlightSearchTool
    A tool you use to make your app’s custom data available to Foundation Models.
  • St
    CoreSpotlightSource
    A search source that retrieves data from the app’s Spotlight index.
  • St
    FileSource
    A search source that retrieves indexed metadata from files and directories visible to Spotlight.
  • St
    SearchSource
    A source of data for Spotlight to search.
  • St
    SearchPipelineData
    The value that flows between pipeline stages, carrying a typed payload.
  • En
    SearchPipelineDataType
    Declares the kind of data a pipeline stage accepts or produces.
  • St
    SearchResultsTable
    Tabulated result data — rows with typed columns for display or spreadsheet export.
  • St
    ScoredSearchableItem
    A searchable item paired with a caller-assigned relevance score.
  • St
    SearchableItemAttribute
    A structure that represents a single metadata attribute of a searchable item.
  • St
    SearchTextResult
    LLM-generated text summary or analysis from a pipeline stage.
  • St
    SearchCount
    A scalar count result (e.g., "47 emails from John").
  • St
    SearchStatistic
    A 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.

  • Pr
    ContactResolver
    Resolves the current user's identity for search queries involving people.
  • St
    ResolvedContact
    Contact 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.

  • Pr
    CustomStage
    A custom processing stage in a Spotlight search pipeline.

Extends 2

NSUserActivityNSAttributedString
← Data, Storage & Cloud