IndexedEntityQuery
protocol · iOS 27.0+ · SDK 27.1
protocol IndexedEntityQuery : EntityQuery where Self.Entity : IndexedEntityAn interface that adds Spotlight reindexing support to your entity query. Adopt this protocol in query types for app entities that you donate to your app’s Spotlight index using the <doc://com.apple.documentation/documentation/corespotlight/cssearchableindex/indexappentities(_:priority:)> method. When the system encounters an issue with an app’s index, it can ask that app to reindex its content. During reindexing, the system calls the methods of this protocol if your query type supports the protocol. If your type doesn't support the protocol, Spotlight continues to ask your app's <doc://com.apple.documentation/documentation/corespotlight/cssearchableindexdelegate> object to reindex any content. Similarly, if you donated an entity by associating it with a <doc://com.apple.documentation/documentation/corespotlight/cssearchableitem> type, Spotlight uses your <doc://com.apple.documentation/documentation/corespotlight/cssearchableindexdelegate> object. Implement the methods of this protocol and use them to retrieve the specified entities and donate them again to Spotlight. The following example shows the implementation of this protocol for a photos app. The methods fetch the requested app entities and donate them again using the app’s preferred searchable index. ```swift struct PhotoQuery: IndexedEntityQuery { func reindexEntities(for identifiers: [PhotoEntity.ID], indexDescription: CSSearchableIndexDescription) async throws { let photos = try await photoStore.fetch(ids: identifiers) try await CSSearchableIndex(name: “MyPhotosApp”).indexAppEntities(photos) } func reindexAllEntities(indexDescription: CSSearchableIndexDescription) async throws { let allPhotos = try await photoStore.fetchAll() try await CSSearchableIndex(name: “MyPhotosApp”).indexAppEntities(allPhotos) } } ``` For more information about indexing your app entites, see <doc:making-app-entities-available-in-spotlight>.
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
No declarations were skipped in this snapshot.