<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreSpotlight",
  "identifier" : "/documentation/CoreSpotlight/CSSearchableIndex/indexAppEntities(_:priority:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Spotlight",
      "CoreSpotlight"
    ],
    "preciseIdentifier" : "s:So17CSSearchableIndexC10AppIntentsE05indexC8Entities_8priorityySayxG_SitYaKAC13IndexedEntityRzlF"
  },
  "title" : "indexAppEntities(_:priority:)"
}
-->

# indexAppEntities(_:priority:)

Indexes one or more app entities and assigns an optional priority to them.

```
func indexAppEntities(_ appEntities: [some IndexedEntity], priority: Int = 0) async throws
```

## Parameters

`appEntities`

One or more app entities you want to donate to Spotlight. Each entity must
conform to the <doc://com.apple.documentation/documentation/AppIntents/IndexedEntity> protocol.

`priority`

The importance of these donated items relative to your app’s other items.
If you don’t specify a priority, this method assigns a priority of 0 to the items.
Specify a higher number to prioritize the entities over other items you add to the index.
The App Intents system uses priorities to determine what items to show in suggestions and other places.

## Discussion

Use this method to index the <doc://com.apple.documentation/documentation/AppIntents/AppEntity>
instances you create for your app’s content. For each object in `appEntities`, Spotlight identifies the
indexable content and adds it to your app’s index. However, the indexing process isn’t recursive,
and this method doesn’t index any child entities contained inside your entity objects. To index both
parent and child entities, you must add each object separately to the `appEntities` parameter.

Indexing your app’s entities has some specific benefits. If your app also provides
<doc://com.apple.documentation/documentation/AppIntents/OpenIntent> types for its entities,
Spotlight can use those types to open your app and display an entity’s content when someone
selects it in search results.

Call this method as an alternative to creating and indexing [`CSSearchableItem`](/documentation/CoreSpotlight/CSSearchableItem) types for your
content. If you index a searchable item and entity for the same content, Spotlight creates separate
entries for each one in your app’s index. If you want to use your existing code to create searchable
items, you can call the [`associateAppEntity(_:priority:)`](/documentation/CoreSpotlight/CSSearchableItemAttributeSet/associateAppEntity(_:priority:)) method to
associate an entity with each of your items. Doing so gives you the same benefits as indexing
the entity on its own, without creating multiple entries for the item in the app’s index.

---

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)