<!--
{
  "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/indexSearchableItems(_:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Spotlight"
    ],
    "preciseIdentifier" : "c:objc(cs)CSSearchableIndex(im)indexSearchableItems:completionHandler:"
  },
  "title" : "indexSearchableItems(_:completionHandler:)"
}
-->

# indexSearchableItems(_:completionHandler:)

Adds or updates items in the index.

```
func indexSearchableItems(_ items: [CSSearchableItem], completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

## Parameters

`items`

An array of searchable items to add or update.

`completionHandler`

The block that’s called when the data has been journaled by the index, which means that the index makes a note that it has to perform this operation. If the completion handler returns an error, it means that the data wasn’t journaled correctly and the client should retry the request.

    The block receives the following parameter:

- error: If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is `nil`.

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> func indexSearchableItems(_ items: [CSSearchableItem]) async throws
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

The [`searchableIndex(_:reindexSearchableItemsWithIdentifiers:acknowledgementHandler:)`](/documentation/CoreSpotlight/CSSearchableIndexDelegate/searchableIndex(_:reindexSearchableItemsWithIdentifiers:acknowledgementHandler:)) protocol method is called in the case that the journaling completed successfully but the data was not able to be indexed for some reason.

---

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)