> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# SearchService

**Published**: 2026-11-30
**Category**: Services

Full-text search with typo tolerance over the site's published articles and, when the site
opts commerce into search, its products, product categories and product collections.
Accessible as `lynkow.search`. Search must be enabled for the site: otherwise every
method throws `LynkowError` `SERVICE_UNAVAILABLE`.

Access via: `lynkow.search`

## Methods

**4** methods

### `getConfig`

```typescript
getConfig(options?: BaseRequestOptions): Promise<SearchConfig>
```

Fetches what a browser needs to query Lynkow search directly: the `host`, a tenant token
(`apiKey`) valid for 1 hour and limited to this site's records, and the `indexName`.
Fetch it again before the token expires. With `cache: true`, cached for 10 minutes.
Throws `LynkowError` `SERVICE_UNAVAILABLE` when search is off for the site or browser
search is unavailable.

| Parameter | Type | Description |
| --- | --- | --- |
| `options` | `BaseRequestOptions` | Request options, such as `fetchOptions`. |


Returns: `Promise<SearchConfig>`

```typescript
const { host, apiKey, indexName } = await lynkow.search.getConfig()
// indexName: 'site_550e8400_e29b_41d4_a716_446655440000'
```

---

### `listProfiles`

```typescript
listProfiles(options?: BaseRequestOptions): Promise<SearchProfilePublic[]>
```

Lists the site's public search profiles, the default profile first, then by name. A
profile is a search scope set up in the admin, with its own fields, facets, sort and
limits: pass its `slug` to SearchService.searchByProfile. With `cache: true`,
cached for 10 minutes. Throws `LynkowError` `SERVICE_UNAVAILABLE` when search is off
for the site.

| Parameter | Type | Description |
| --- | --- | --- |
| `options` | `BaseRequestOptions` | Request options, such as `fetchOptions`. |


Returns: `Promise<SearchProfilePublic[]>`

```typescript
const profiles = await lynkow.search.listProfiles()
for (const profile of profiles) {
  console.log(profile.slug, profile.name)
}
```

---

### `search`

```typescript
search(query: string, options?: SearchOptions): Promise<SearchResponse>
```

Searches the site through its default search profile. Hits are articles plus, when
commerce is opted into search, products, product categories and product collections:
check each hit's `type`. Hits come ordered by relevance; treat every hit field as
optional. With a locale, a hit untranslated in it is returned with `isFallback: true`.
An empty query resolves to no hits. Throws `LynkowError` `SERVICE_UNAVAILABLE`
(`apiCode` `INTERNAL_SERVICE_UNAVAILABLE`) when search is off for the site.

| Parameter | Type | Description |
| --- | --- | --- |
| `query` | `string` | The search text. Typos are tolerated: `'pagniation'` finds pagination. |
| `options` | `SearchOptions` | `locale`, `fallback: false`, `category`, `tag`, `page`, `limit` and `market`. See SearchOptions. |


Returns: `Promise<SearchResponse>`

```typescript
const { data, meta } = await lynkow.search.search('formulaire', {
  locale: 'fr',
  category: 'guides',
  limit: 5,
})
for (const hit of data) {
  console.log(hit._formatted?.title ?? hit.title, hit.path, hit.isFallback)
}
```

---

### `searchByProfile`

```typescript
searchByProfile(profileSlug: string, query: string, options?: SearchOptions): Promise<SearchResponse>
```

Searches through one public search profile, which applies its scope, fields, sort and
limits. Options work as on SearchService.search and narrow the profile's scope.
On page 1 the profile's featured hits come first, flagged `_isFeatured`, then its
boosted hits, flagged `_isBoosted`. Throws `LynkowError` `NOT_FOUND` for an unknown
profile or an empty, `'.'` or `'..'` slug, `FORBIDDEN` (`apiCode`
`AUTHZ_PERMISSION_DENIED`) for a private one, and `SERVICE_UNAVAILABLE` when search is off.

| Parameter | Type | Description |
| --- | --- | --- |
| `profileSlug` | `string` | The slug of a public profile, such as `'api-docs'`. |
| `query` | `string` | The search text. Typos are tolerated. |
| `options` | `SearchOptions` | `locale`, `fallback: false`, `category`, `tag`, `page`, `limit` and `market`. See SearchOptions. |


Returns: `Promise<SearchResponse>`

```typescript
const results = await lynkow.search.searchByProfile('api-docs', 'pagination', {
  limit: 10,
})
```