# Search (/docs/search)

Find a document by what it contains, then open the page behind the match. You can search across your workspace or within one document.

Search is available on **Growth** and **Team** plans. Eligible document content is indexed automatically when your workspace’s plan includes Search. Start with a processed document, such as the statement from the [portal](/docs/portal-quickstart) or [SDK quickstart](/docs/sdk-quickstart).

## Search in your own words [#search-in-your-own-words]

Try `monthly account fees` to find a passage about a "Monthly service fee." Open the matching page to read the charge beside its source.

Search can match meaning as well as words, so your query does not have to repeat the document’s wording. Results point you to content to inspect; Search does not write an answer to your question.

## Find a document in the portal [#find-a-document-in-the-portal]

Open **Search** from the left navigation, or press **⌘K** on Mac or **Ctrl+K** on Windows and Linux. Enter `monthly account fees` and press **Enter**.

Each result represents a document. When search finds matching page content, the result includes a plain-text excerpt and page number. Select it to open that page. A match on the filename alone is labelled **Filename match**. An exact external identifier match shows **External ID** or **External group ID** and the matching value. Identifier and filename matches open the document without a page excerpt.

Workspace search returns each document once. Content matches include one representative page. To find other passages in the same file, search within that document.

## Find a page within a document [#find-a-page-within-a-document]

Open the statement and enter your query in **Search this document**, then press **Enter**. Each result represents a matching page in that file. Select a result to inspect its source image and extracted text.

Try `"monthly service fee"` to find the charge on page 3 of the sample statement. This uses word matching, as explained below.

## Choose words more precisely [#choose-words-more-precisely]

Quotes, uppercase `OR`, or a minus before a word switch the query to lexical search: matching words rather than expanding by meaning. These forms work in both workspace and document searches.

| Query                   | What it asks for                                   |
| ----------------------- | -------------------------------------------------- |
| `"monthly service fee"` | Keep the words together as a phrase.               |
| `transfer OR fee`       | Find either word.                                  |
| `transfer -savings`     | Find transfers while excluding the word "savings." |

Phrase matching follows the search engine's language rules, including word forms. It is not a comparison of the exact characters. Use uppercase `OR` for the operator; lowercase `or` leaves semantic matching enabled unless the query contains other explicit syntax.

A signed number such as `-250` stays a numeric search term. The minus does not exclude `250`, and a signed number alone does not turn off semantic matching.

## Search with the SDK [#search-with-the-sdk]

Use the installation and API key from the [SDK quickstart](/docs/sdk-quickstart). The key needs **Read results** permission and must belong to a workspace with Search access.

To search across that workspace, save this as `search.mjs`:

```js
import { Pagelet } from "@pagelet-ai/sdk"

const client = new Pagelet()
const results = await client.documents.search({ query: "monthly account fees" })

for (const hit of results.hits) {
  console.log(hit.document.filename, hit.identifier?.value ?? hit.page?.excerpt ?? "Filename match")
}
```

Run `node --env-file=.env search.mjs` from the folder containing your `.env` file.

To search the statement as part of the quickstart script, add this after its `documents.create` call. It uses that script's `client` and `result`:

```js
const matches = await client.documents.search({
  filters: { documentId: result.document.id },
  query: '"monthly service fee"',
})

for (const hit of matches.hits) {
  console.log(hit.page?.page_number, hit.page?.excerpt)
}
```

For later searches, save `result.document.id` and pass it as `filters.documentId`. You don't need to upload the file again.

Search returns up to five hits by default. Set `limit` to a number from 1 to 10 to change that. Results are ranked matches, not an exhaustive list of every occurrence.

## Search within an application’s documents [#search-within-an-applications-documents]

Use the external group ID supplied when uploading to restrict the search:

```js
const matches = await client.documents.search({
  query: "termination clauses",
  filters: { externalGroupId: "application-42" },
})
```

Every result must match all supplied filters. You can also use `filters.externalId` to restrict results to an external document ID. IDs are case-sensitive. A group search returns each matching document once; use `filters.documentId` to find individual pages within one document.

See the [Search API reference](/docs/api/documents/searchDocuments) for direct HTTP requests.

## Find documents by an identifier [#find-documents-by-an-identifier]

Paste a complete external document or group ID into the portal search box, or pass it as `query`:

```js
const matches = await client.documents.search({ query: "application-42" })
```

Enter the complete ID, including its case and punctuation. Surrounding spaces are ignored. Exact identifier matches appear first and can find documents before their page content is ready.

Putting an ID in `query` does not restrict the search to that group. Use `filters.externalGroupId` when every result must belong to it. To retrieve every retained document in a group, use the paginated list:

```js
const documents = await client.documents.list({
  filters: { externalGroupId: "application-42" },
})
```

Follow `pagination.next_start` to collect the remaining documents, as shown in the [SDK reference](/docs/sdk-reference#documentslist). Listing documents does not require Search access.

## If you don't find what you expected [#if-you-dont-find-what-you-expected]

Newly processed content may take a little longer to become searchable. Retry after a short wait. If a page's extraction failed or its content has expired, search cannot recover that text. Open the document to check its result.

Try a distinctive phrase from the page or a filename if a broad query doesn't find it. No results does not prove that the information is absent.

If the portal reports that Search is unavailable, check **Plan & Billing** and your workspace access. A search-limit message means you need to wait before trying again.
