<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/IndexedEntityQuery",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "App Intents"
    ],
    "preciseIdentifier" : "s:10AppIntents18IndexedEntityQueryP"
  },
  "title" : "IndexedEntityQuery"
}
-->

# IndexedEntityQuery

An interface that adds Spotlight reindexing support to your entity query.

```
protocol IndexedEntityQuery : EntityQuery where Self.Entity : IndexedEntity
```

## Overview

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 [Making app entities available in Spotlight](/documentation/AppIntents/making-app-entities-available-in-spotlight).

## Relationships

### Inherits From

[`PersistentlyIdentifiable`](/documentation/AppIntents/PersistentlyIdentifiable)

[`Sendable`](/documentation/Swift/Sendable)

[`DynamicOptionsProvider`](/documentation/AppIntents/DynamicOptionsProvider)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`EntityQuery`](/documentation/AppIntents/EntityQuery)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)