---
title: "indexSearchableItems(_:completionHandler:)"
framework: corespotlight
role: symbol
role_heading: Instance Method
path: "corespotlight/cssearchableindex/indexsearchableitems(_:completionhandler:)"
---

# indexSearchableItems(_:completionHandler:)

Adds or updates items in the index.

## Declaration

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

```swift
func indexSearchableItems(_ items: [CSSearchableItem]) async throws
```

## 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:

## Mentioned in

Adding your app’s content to Spotlight indexes

## Discussion

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: func indexSearchableItems(_ items: [CSSearchableItem]) async throws For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. The 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.

## See Also

### Managing items in an index

- [deleteAllSearchableItems(completionHandler:)](corespotlight/cssearchableindex/deleteallsearchableitems(completionhandler:).md)
- [deleteSearchableItems(withDomainIdentifiers:completionHandler:)](corespotlight/cssearchableindex/deletesearchableitems(withdomainidentifiers:completionhandler:).md)
- [deleteSearchableItems(withIdentifiers:completionHandler:)](corespotlight/cssearchableindex/deletesearchableitems(withidentifiers:completionhandler:).md)
