---
title: "deleteSpotlightIndex(completionHandler:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nscoredatacorespotlightdelegate/deletespotlightindex(completionhandler:)"
---

# deleteSpotlightIndex(completionHandler:)

Deletes all searchable items from the configured index.

## Declaration

```swift
func deleteSpotlightIndex(completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func deleteSpotlightIndex() async throws
```

## Discussion

Discussion The closure returns no value and takes only a single parameter, which is an error object that contains information about issues preventing the deletion of searchable items, or nil if Core Spotlight successfully deletes all searchable items. Depending on the cause of the issue, an error can originate from Core Data or from Core Spotlight. Make sure your app can handle both scenarios. note: You must call stopSpotlightIndexing() before you call this method; otherwise, Core Data immediately recreates the index.

## See Also

### Managing the Index

- [attributeSet(for:)](coredata/nscoredatacorespotlightdelegate/attributeset(for:).md)
- [startSpotlightIndexing()](coredata/nscoredatacorespotlightdelegate/startspotlightindexing().md)
- [stopSpotlightIndexing()](coredata/nscoredatacorespotlightdelegate/stopspotlightindexing().md)
