Contents

CSSearchQuery

A type you use to programmatically search the indexed app content.

Declaration

class CSSearchQuery

Mentioned in

Overview

Use a CSSearchQuery object to search your app’s indexed content using a formatted search string. To perform a search, build a predicate string to specify the indexed attributes you want to search and the value you want them to match. After you start the query, you receive batches of results in the handlers you provide.

Each CSSearchQuery object you create performs a single search operation and delivers the results back to your code. Build each predicate with an attribute name, one or more values, and either a comparison operator or the InRange operator. Your predicate string takes one of the following forms:

  • attributeName operator value[modifiers]

  • InRange(attributeName, minValue, maxValue)

Queries search all of your app’s indexes by default. If your app encrypts some of its indexed data, you can limit your search to one or more of the encrypted indexes by updating the query’s protectionClasses property. The query must have access to the protected index to search it.

For more information about how to construct predicate strings for your query, see Searching for information in your app.

Topics

Creating a query object

Continuing an activity

Specifying the indexes to search

Executing the query automatically

Executing the query with handler blocks

See Also

Queries