<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreSpotlight",
  "identifier" : "/documentation/CoreSpotlight/CSSearchableIndex",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Spotlight"
    ],
    "preciseIdentifier" : "c:objc(cs)CSSearchableIndex"
  },
  "title" : "CSSearchableIndex"
}
-->

# CSSearchableIndex

An on-device index for your app’s searchable content.

```
class CSSearchableIndex
```

## Overview

A `CSSearchableIndex` object manages an on-device index for your app’s
searchable content. To make your app’s content searchable, create one or more
[`CSSearchableItem`](/documentation/CoreSpotlight/CSSearchableItem) objects for your content and add those items to the index.
If your app defines <doc://com.apple.documentation/documentation/AppIntents/AppEntity>
types, you can also index those types directly or associate them with your [`CSSearchableItem`](/documentation/CoreSpotlight/CSSearchableItem)
objects. When you execute a query, Core Spotlight searches your indexes for the requested
information and returns the results to your code.

Create custom `CSSearchableIndex` objects in your production code to store your app’s content,
instead of using the default index. Custom indexes support data protection, which allows
you to encrypt your data and protect it from unauthorized access. Custom indexes also
support batch operations, which allow you to index large amounts of data more efficiently
and with less risk. For example, you can add custom state information to each batch operation
to make it easier to restart the indexing process if your app or app extension crashes. Use the
default index only during testing or prototyping of your features.

Modify a `CSSearchableIndex` object from only one thread or task at a time, and modify it
only from your signed app or app extension. It’s a programming error to access a custom
index from multiple threads simultaneously or from an unsigned bundle. When performing batch
updates on an index, start each new batch operation only after calling the
[`endBatch(withClientState:completionHandler:)`](/documentation/CoreSpotlight/CSSearchableIndex/endBatch(withClientState:completionHandler:)) or
[`endIndexBatch(expectedClientState:newClientState:completionHandler:)`](/documentation/CoreSpotlight/CSSearchableIndex/endIndexBatch(expectedClientState:newClientState:completionHandler:))
method of the previous batch operation.

> Note: If your app creates <doc://com.apple.documentation/documentation/Foundation/NSUserActivity>
> objects, set the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity/isEligibleForSearch>
> property of those objects to `true` if you want them to appear in search results.

## Topics

### Creating an index

[`+  defaultSearchableIndex`](/documentation/CoreSpotlight/CSSearchableIndex/default())

Returns the default on-device index.

[`-  initWithName:`](/documentation/CoreSpotlight/CSSearchableIndex/init(name:))

Returns an on-device index with the specified name.

[`-  initWithName:protectionClass:`](/documentation/CoreSpotlight/CSSearchableIndex/init(name:protectionClass:))

Returns an on-device index with the specified name and data protection class.

### Determining if indexing is available

[`+  isIndexingAvailable`](/documentation/CoreSpotlight/CSSearchableIndex/isIndexingAvailable())

Returns a Boolean value that indicates whether indexing is available
on the current device.

### Responding to index-related changes

[`CSSearchableIndexDelegate`](/documentation/CoreSpotlight/CSSearchableIndexDelegate)

A protocol that defines methods a delegate object or app extension uses to handle communication from the on-device index.

[`indexDelegate`](/documentation/CoreSpotlight/CSSearchableIndex/indexDelegate)

The delegate object that can handle index-management tasks.

### Managing items in an index

[`-  indexSearchableItems:completionHandler:`](/documentation/CoreSpotlight/CSSearchableIndex/indexSearchableItems(_:completionHandler:))

Adds or updates items in the index.

[`-  deleteAllSearchableItemsWithCompletionHandler:`](/documentation/CoreSpotlight/CSSearchableIndex/deleteAllSearchableItems(completionHandler:))

Deletes all searchable items from the index.

[`-  deleteSearchableItemsWithDomainIdentifiers:completionHandler:`](/documentation/CoreSpotlight/CSSearchableIndex/deleteSearchableItems(withDomainIdentifiers:completionHandler:))

Removes from the index all searchable items associated with the specified domain.

[`-  deleteSearchableItemsWithIdentifiers:completionHandler:`](/documentation/CoreSpotlight/CSSearchableIndex/deleteSearchableItems(withIdentifiers:completionHandler:))

Removes from the index all items with the specified identifiers.

### Indexing app entities

[`indexAppEntities(_:priority:)`](/documentation/CoreSpotlight/CSSearchableIndex/indexAppEntities(_:priority:))

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

[`deleteAppEntities(ofType:)`](/documentation/CoreSpotlight/CSSearchableIndex/deleteAppEntities(ofType:))

Deletes all app entities of the specified type from the current index.

[`deleteAppEntities(identifiedBy:ofType:)`](/documentation/CoreSpotlight/CSSearchableIndex/deleteAppEntities(identifiedBy:ofType:))

Deletes entities with the specified identifiers and type from the current index.

### Batching index updates

[`-  beginIndexBatch`](/documentation/CoreSpotlight/CSSearchableIndex/beginBatch())

Begins a batch of updates to an index.

[`-  endIndexBatchWithClientState:completionHandler:`](/documentation/CoreSpotlight/CSSearchableIndex/endBatch(withClientState:completionHandler:))

Ends a batch of index updates and stores the specified state information.

[`-  endIndexBatchWithExpectedClientState:newClientState:completionHandler:`](/documentation/CoreSpotlight/CSSearchableIndex/endIndexBatch(expectedClientState:newClientState:completionHandler:))

Ends a batch of index updates and stores the specified state information.

[`-  fetchLastClientStateWithCompletionHandler:`](/documentation/CoreSpotlight/CSSearchableIndex/fetchLastClientState(completionHandler:))

Fetches the app’s most recent client state information asynchronously.

### Handling drag and drop content

[`-  fetchDataForBundleIdentifier:itemIdentifier:contentType:completionHandler:`](/documentation/CoreSpotlight/CSSearchableIndex/fetchData(forBundleIdentifier:itemIdentifier:contentType:completionHandler:))

Fetches data from an external provider.

### Getting the protection class

[`protectionClass`](/documentation/CoreSpotlight/CSSearchableIndex/protectionClass)

## Relationships

### Conforms To

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

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

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

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

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

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)