---
title: IndexedEntityQuery
framework: appintents
role: symbol
role_heading: Protocol
path: appintents/indexedentityquery
---

# IndexedEntityQuery

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

## Declaration

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

## Mentioned in

Making app entities available in Spotlight Defining app entities for your custom data types

## Overview

Overview Adopt this protocol in query types for app entities that you donate to your app’s Spotlight index using the 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 CSSearchableIndexDelegate object to reindex any content. Similarly, if you donated an entity by associating it with a CSSearchableItem type, Spotlight uses your 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. 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.

## Topics

### Instance Methods

- [reindexAllEntities(indexDescription:)](appintents/indexedentityquery/reindexallentities(indexdescription:).md)
- [reindexEntities(for:indexDescription:)](appintents/indexedentityquery/reindexentities(for:indexdescription:).md)

## Relationships

### Inherits From

- [DynamicOptionsProvider](appintents/dynamicoptionsprovider.md)
- [EntityQuery](appintents/entityquery.md)
- [PersistentlyIdentifiable](appintents/persistentlyidentifiable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Spotlight support

- [IndexedEntity](appintents/indexedentity.md)
