View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Support semantic search with Core Spotlight

    Learn how to provide semantic search results in your app using Core Spotlight. Understand how to make your app's content available in the user's private, on-device index so people can search for items using natural language. We'll also share how to optimize your app's performance by scheduling indexing activities.

    To get the most out of this session, we recommend first checking out Core Spotlight documentation on the Apple Developer website.

    Chapitres

    • 0:00 - Introduction
    • 1:37 - Searchable content
    • 5:05 - Demo: Creating an index delegate extension
    • 6:56 - Results and suggestions
    • 9:18 - Ranking
    • 10:17 - Wrap-up

    Ressources

    • Forum: UI Frameworks
    • Core Spotlight
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC24

    • Bring your app’s core features to users with App Intents

    WWDC21

    • Showcase app data in Spotlight
  • Rechercher dans cette vidéo…
    • 2:14 - Creating CSSearchableItem

      // Creating searchable items for donation
      
      
      let item = CSSearchableItem(uniqueIdentifier: uniqueIdentifier, domainIdentifier: domainIdentifier, attributeSet: attributeSet)
    • 2:28 - Creating CSSearchableAttributeSet

      // Creating searchable content for donation
      
      
      let attributeSet = CSSearchableItemAttributeSet(contentType: UTType.text)
      attributeSet.contentType = UTType.text.identifier
    • 2:40 - Searchable items with type

      // Searchable items with text
      
      
      attributeSet.title
      attributeSet.textContent
      
      
      // Searchable items with media
      
      
      attributeSet.contentType
      attributeSet.contentURL
      
      
      // Searchable items with links
      
      
      attributeSet.contentURL
      attributeSet.relatedUniqueIdentifier
    • 3:31 - Batch indexing with client state

      // Batch indexing with client state
      
      
      let index = CSSearchableIndex(name: "SpotlightSearchSample")        
      index.fetchLastClientState { state, error in         
          if state == nil {
              index.beginBatch()
              index.indexSearchableItems(items)
              index.endIndexBatch(expectedClientState: state, newClientState: newState) { error in
              }
          }
      }
    • 3:56 - Avoid overwriting existing attributes

      // Make it an update to avoid overwriting existing attributes
      
      
      item.isUpdate = true
    • 7:19 - Configure a query

      // Configure a query
      
      
      let queryContext = CSUserQueryContext()
      queryContext.fetchAttributes = ["title", "contentDescription"]
    • 7:33 - Ranked results

      // Ranked results
      
      
      queryContext.enableRankedResults = true
      queryContext.maxRankedResultCount = 2
    • 7:47 - Suggestions

      // Suggestions
      
      
      queryContext.maxSuggestionCount = 4
    • 7:55 - Filter queries

      // Filter queries
      
      
      queryContext.filterQueries = ["contentTypeTree=\"public.image\""]
    • 8:23 - Query for searchable items and suggestions

      // Query for searchable items and suggestions
      
      
      let query = CSUserQuery(userQueryString: "windsurfing carmel", userQueryContext: queryContext)
      for try await element in query.responses {
          switch(element) {
              case .item(let item):
                  self.items.append(item)
                  break
              case .suggestion(let suggestion):
                  self.suggestions.append(suggestion)
                  break
          }
      }
    • 8:40 - Suggestions

      // Suggestions
      
      
      suggestion.localizedAttributedSuggestion
    • 8:56 - Preparing for queries

      // Preparing for queries
      
      
      CSUserQuery.prepare
      CSUserQuery.prepareWithProtectionClasses
    • 9:50 - Set the lastUsedDate

      // Set the lastUsedDate when the user interacts with the item
      
      
      item.attributeSet.lastUsedDate = Date.now
      item.isUpdate = true
    • 10:00 - Interactions with items and suggestions from a query

      // Interactions with items and suggestions from a query
      
      
      query.userEngaged(item, visibleItems: visibleItems, interaction: CSUserQuery.UserInteractionKind.select)
      
      query.userEngaged(suggestion, visibleSuggestions: visibleSuggestions, interaction: CSUserQuery.UserInteractionKind.select)

Developer Footer

  • Vidéos
  • WWDC24
  • Support semantic search with Core Spotlight
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines