---
title: "spotlightQuery(_:)"
framework: appintentstesting
role: symbol
role_heading: Instance Method
path: "appintentstesting/appentitydefinition/spotlightquery(_:)"
---

# spotlightQuery(_:)

Performs a Spotlight search query for entities of this type.

## Declaration

```swift
func spotlightQuery(_ userQuery: String? = nil) async throws -> [AnyAppEntity]
```

## Parameters

- `userQuery`: The search query string. If nil, returns all indexed entities.

## Mentioned in

Testing your App Intents code

## Return Value

Return Value An array of AnyAppEntity instances that match the search criteria.

## Discussion

Discussion note: An error if the spotlight query fails.

## See Also

### Searching matching entities

- [entities(identifiers:)](appintentstesting/appentitydefinition/entities(identifiers:).md)
- [entityQuery(identifiers:)](appintentstesting/appentitydefinition/entityquery(identifiers:).md)
- [entities(matching:)](appintentstesting/appentitydefinition/entities(matching:).md)
- [entityQuery(matching:)](appintentstesting/appentitydefinition/entityquery(matching:).md)
