Skip to main content
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.

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. Words match as spelled, with or without a trailing “s”. Long words can be a letter or two off, since text on signs is often misread.
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.
  • sensitivity: kinds of sensitive content, such as an ID, a health document or nudity.
  • score, relevance, matchedText and matchReasons: why it matched.
  • activities and context: what was done on its visit, and the circumstances.
  • people: the people whose faces are in it, with people on.
  • duplicates: other photos of the same shot. Search shows them once, as this result.
See SearchResults for every field.

How many results

search returns the 500 most relevant results by default. results.totalCount says how many there were, so you can tell when results were cut. Pass limit for another number, or nil for every result. Only the results returned are read from the index, so a smaller limit is faster on large libraries.
For the next page, pass offset: the number of results to skip. The order is fixed, so pages of the same index don’t overlap or skip.
Pages can shift if the index changes between calls, for example while indexing adds photos. If a page’s totalCount differs from the first page’s, start again from offset 0.

Sensitive photos

Search does not leave out photos and screenshots with sensitive content. Their sensitivity is not empty. Drop them before anything leaves the iPhone. query, facets, indexing batches and people() leave them out on their own. See Sensitive photos.

Searching for people

With people on, search(_:people:) keeps only photos with every one of those people in them, then applies limit and offset. Get their ids from people().

Loading images

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

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.