---
title: "search(query, options)"
framework: mapkitjs
role: symbol
role_heading: Instance Method
path: mapkitjs/search/search
---

# search(query, options)

Retrieves the results of a search query.

## Declaration

```data
search(
    query: string | SearchAutocompleteResult,
    options?: SearchOptions,
): Promise<SearchResponse>;
```

## Parameters

- `query`: A String or a doc://com.apple.mapkitjs/documentation/MapKitJS/SearchAutocompleteResult.
- `options`: Options for this specific query that supersede values set on the doc://com.apple.mapkitjs/documentation/MapKitJS/Search object. See doc://com.apple.mapkitjs/documentation/MapKitJS/SearchOptions.

## Return Value

Return Value A promise that resolves with a SearchResponse on success, or rejects with an Error on failure.

## Discussion

Discussion The search(query, options) method returns a set of locations that matches a user-entered query or a SearchAutocompleteResult. The resolved SearchResponse contains the following properties: places (array of Place). An array of Place objects. The places array is empty if there isn’t a match. query (String). The query that corresponds to the results, if you don’t use SearchAutocompleteResult to perform the search. Optional. boundingRegion (CoordinateRegion). A region that encloses the search results. This property isn’t present if there aren’t any results. Pass an AbortSignal from an AbortController to the signal option to allow the controller to cancel a pending request. When the controller aborts, the promise it returns rejects with a DOMException whose name is "AbortError". The following example searches for coffee shop in and around the visible map area, and adds the results as annotations: const search = new mapkit.Search({ region: map.region });

try {     const data = await search.search("coffee shop");     const annotations = data.places.map((place) => {         const annotation = new mapkit.MarkerAnnotation(place.coordinate);         annotation.title = place.name;         annotation.subtitle = place.formattedAddress;         annotation.color = "#9B6134";         return annotation;     });     map.showItems(annotations); } catch (error) {     // Handle the search error. }

## See Also

### Performing a search

- [SearchDelegate](mapkitjs/searchdelegate.md)
- [SearchOptions](mapkitjs/searchoptions.md)
- [SearchResponse](mapkitjs/searchresponse.md)
