---
title: CSSearchQuery
framework: corespotlight
role: symbol
role_heading: Class
path: corespotlight/cssearchquery
---

# CSSearchQuery

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

## Declaration

```swift
class CSSearchQuery
```

## Mentioned in

Searching for information in your app

## Overview

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

- [init(queryString:attributes:)](corespotlight/cssearchquery/init(querystring:attributes:).md)
- [init(queryString:queryContext:)](corespotlight/cssearchquery/init(querystring:querycontext:).md)

### Continuing an activity

- [CSSearchQueryString](corespotlight/cssearchquerystring.md)
- [CSQueryContinuationActionType](corespotlight/csquerycontinuationactiontype.md)

### Specifying the indexes to search

- [protectionClasses](corespotlight/cssearchquery/protectionclasses.md)

### Executing the query automatically

- [results](corespotlight/cssearchquery/results-swift.property.md)
- [CSSearchQuery.Results](corespotlight/cssearchquery/results-swift.struct.md)

### Executing the query with handler blocks

- [start()](corespotlight/cssearchquery/start().md)
- [cancel()](corespotlight/cssearchquery/cancel().md)
- [isCancelled](corespotlight/cssearchquery/iscancelled.md)
- [foundItemCount](corespotlight/cssearchquery/founditemcount.md)
- [foundItemsHandler](corespotlight/cssearchquery/founditemshandler.md)
- [completionHandler](corespotlight/cssearchquery/completionhandler.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [CSUserQuery](corespotlight/csuserquery.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Queries

- [Building a search interface for your app](corespotlight/building-a-search-interface-for-your-app.md)
- [Searching for information in your app](corespotlight/searching-for-information-in-your-app.md)
- [CSUserQuery](corespotlight/csuserquery.md)
- [CSUserQueryContext](corespotlight/csuserquerycontext.md)
- [CSSearchQueryContext](corespotlight/cssearchquerycontext.md)
- [CSSuggestion](corespotlight/cssuggestion.md)
