> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tryrollup.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search

> Search the person's camera roll on the iPhone with a natural-language query.

`search` runs on the iPhone against the index. It needs no network connection. Rollup learns only how many searches ran, as a count in the SDK's run reports, never what was searched.

```swift theme={null}
let results = try await Rollup.shared.search("sushi in Tokyo last spring")
for result in results.results {
    print(result.id, result.date as Any, result.places.first?.name as Any)
}
```

## What a query can say

Search reads the parts of the query it understands and matches the rest against what photos show and say:

* **Dates**, such as "last spring", "in March", "2025" or a holiday.
* **Media**, such as "videos" or "screenshots".
* **Places**: countries, cities, neighborhoods, venue names and kinds of places, such as "ramen" or "museum".
* **What photos show**, matched against the image and its labels.
* **Text in images**, such as signs, menus and screenshots.

`results.plan` tells you how search read the query: its `operation`, its `retrievalIntent`, the `visualText` left to match after dates, media and places, and the `sort`.

## Results

Results come most relevant first. Each `SearchResult` carries what the index holds about the asset:

* `id`: the PhotoKit local identifier. Load the image yourself with PhotoKit.
* `date` and `timeZone`: when and in which time zone it was taken.
* `mediaType` and `isFavorite`.
* `location`: neighborhood, city, metro, country and coordinates.
* `places` and `cuisines`: the venue its visit resolved to, and cuisines for food photos. Empty when `places` is off.
* `labels`: what the photo shows, with probabilities.
* `text`: text read from the image, and `screenshot` for what was read from a screenshot.
* `score`, `relevance`, `matchedText` and `matchReasons`: why it matched.

See [SearchResults](/reference/search-results) for every field.

## Loading images

The SDK returns identifiers, not images. Use PhotoKit to load them:

```swift theme={null}
import Photos

let assets = PHAsset.fetchAssets(withLocalIdentifiers: results.results.map(\.id), options: nil)
```

## Errors

* `noIndex`: nothing is indexed yet. Wait until `indexing.state.isSearchable` is true.
* `notConfigured`: call `configure` first.
* `accessRevoked`: your app's Rollup key no longer works. See [Keys and revocation](/guides/keys-and-revocation).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.