# TextApi.search()

```ts
search(query: string, options?: SearchOptions): Promise<SearchMatch[]>
```

Every match, as `SearchMatch[]`. Needs the `extract` feature.

- Kind: method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `query` | `string` | The text to find. Must not be empty. |
| `options?` | `SearchOptions` | `matchCase` and `matchWholeWord` (both default to `false`), `pages` (zero-based; restrict the search) and `limit` (stop after N matches). |

Returns `Promise<SearchMatch[]>`: Each `{ pageIndex, text, rects }`.

Throws:

- `INVALID_ARGUMENT` — an empty query, or an index in `pages` out of range.
- `PAGE_ERROR` — a page or its text could not be loaded.
- `DOCUMENT_CLOSED` — the document has been closed.
- `FEATURE_NOT_LICENSED` — the license lacks `extract`.

```ts
const onCover = await doc.text.search('Total', { pages: [0], matchWholeWord: true });
```

Part of [TextApi](https://kernstra.com/docs/web-sdk/api/doc-text) in the Kernstra Web SDK 1.0.0 API reference.

Web page: https://kernstra.com/docs/web-sdk/api/doc-text/search
