> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Search

> Full-text search across content, users, and spaces, plus AI-powered Q&A

The `search` module provides server-side access to Sublay's search and AI capabilities. Use it to build search APIs, power recommendation engines, or answer natural-language questions about your content.

***

### searchContent

Searches entities by full-text query, optionally scoped to a space.

```typescript theme={null}
const { data, pagination } = await sublay.search.searchContent({
  query: "getting started guide",
  spaceId: "spc_abc123",
  sourceTypes: ["entity", "comment"],
  limit: 10,
});
```

**query** `string` *required*

The search query string.

**sourceTypes** `string[]`

Which content types to search: any of `"entity"`, `"comment"`, `"message"`. The Node SDK uses a service key, which gets no chat messages, so `"message"` returns nothing.

**spaceId** `string`

Scope the search to a specific space.

**includeChildSpaces** `boolean` (default: false)

Only applies with `spaceId`. When `true`, the search also covers every space nested under it — the whole subtree at any depth — not just the named space. Ignored without `spaceId`.

**conversationId** `string`

Scope the search to a specific conversation. The Node SDK uses a service key, which gets no chat messages, so this returns nothing.

**limit** `number`

Maximum number of results to return.

**spaceReputation** `object`

Opt-in. Adds a `spaceReputation` number to each returned user,
scoped to a single space. Requires the `reputation` bundle.
The `reputation` total is always present regardless;
`spaceReputation` is purely additive and only appears when you
pass this object. **This object is the primary form** — it
replaces the deprecated flat props below. See the
[Reputation data model](https://docs.sublay.io/v7/data-models/reputation.md) for the
full contract.

**spaceReputation**

Which bucket to read. One of: a space **`<uuid>`**
(that space's bucket), **`"none"`** (the
project-general, space-less bucket), or
**`"context"`** (the space derived from the
request context — resolved per-row on lists, or the single space on
member/team/conversation surfaces). The empty string and the legacy
`general` / `null` aliases are rejected (400).
Missing buckets read as `0`.
Only honored when `spaceId` is an explicit space `<uuid>`.
When `true`, `spaceReputation` is the
**subtree sum** — the named space plus all of its
descendant spaces (the root space's own bucket included). Ignored for
`"none"`; not allowed with `"context"`.

**spaceReputationId** `string` *deprecated*

**Deprecated** — use the `spaceReputation`
object instead. The flat form of `spaceReputation.spaceId`.
Still accepted (the object wins if both are passed); removal is a later
major version. Accepts a space `<uuid>`, `"none"`, or
`"context"`.

**spaceReputationDescendants** `boolean` *deprecated*

**Deprecated** — use
`spaceReputation.includeDescendants` instead. The flat form,
only honored alongside an explicit `spaceReputationId` `<uuid>`.

**Returns** — `Promise<PaginatedResponse<Entity>>`

***

### searchUsers

Searches for users by name or username.

```typescript theme={null}
const { data, pagination } = await sublay.search.searchUsers({
  query: "alice",
  limit: 10,
});
```

**query** `string` *required*

The search query string.

**limit** `number`

Maximum number of results to return.

**Returns** — `Promise<PaginatedResponse<User>>`

***

### searchSpaces

Searches for spaces by name or description.

```typescript theme={null}
const { data, pagination } = await sublay.search.searchSpaces({
  query: "photography",
  limit: 10,
});
```

**query** `string` *required*

The search query string.

**limit** `number`

Maximum number of results to return.

**Returns** — `Promise<PaginatedResponse<Space>>`

***

### askContent

Asks a natural-language question about your content and returns an AI-generated answer with source references.

> [!NOTE]
>
> This feature requires semantic search to be enabled for your project. See the [Semantic Search & AI](https://docs.sublay.io/v7/semantic-search-ai.md) guide for setup instructions.

```typescript theme={null}
const { answer, sources } = await sublay.search.askContent({
  query: "What are the best practices for error handling?",
  spaceId: "spc_abc123",
});

// answer: "Based on the content in this space, best practices include..."
// sources: [{ entityId: "ent_xyz", title: "Error Handling Guide" }, ...]
```

**query** `string` *required*

The natural-language question to answer.

**sourceTypes** `string[]`

Which content types to draw from: any of `"entity"`, `"comment"`, `"message"`. The Node SDK uses a service key, which gets no chat messages, so `"message"` returns nothing.

**spaceId** `string`

Scope the search to content within a specific space.

**includeChildSpaces** `boolean` (default: false)

Only applies with `spaceId`. When `true`, the context lookup also covers every space nested under it — the whole subtree at any depth — so you can ask across a community and all of its channels at once. Ignored without `spaceId`.

**conversationId** `string`

Scope the search to a specific conversation. The Node SDK uses a service key, which gets no chat messages, so this returns nothing.

**limit** `number`

Maximum number of sources to draw from.

**spaceReputation** `object`

Opt-in. Adds a `spaceReputation` number to each returned user,
scoped to a single space. Requires the `reputation` bundle.
The `reputation` total is always present regardless;
`spaceReputation` is purely additive and only appears when you
pass this object. **This object is the primary form** — it
replaces the deprecated flat props below. See the
[Reputation data model](https://docs.sublay.io/v7/data-models/reputation.md) for the
full contract.

**spaceReputation**

Which bucket to read. One of: a space **`<uuid>`**
(that space's bucket), **`"none"`** (the
project-general, space-less bucket), or
**`"context"`** (the space derived from the
request context — resolved per-row on lists, or the single space on
member/team/conversation surfaces). The empty string and the legacy
`general` / `null` aliases are rejected (400).
Missing buckets read as `0`.
Only honored when `spaceId` is an explicit space `<uuid>`.
When `true`, `spaceReputation` is the
**subtree sum** — the named space plus all of its
descendant spaces (the root space's own bucket included). Ignored for
`"none"`; not allowed with `"context"`.

**spaceReputationId** `string` *deprecated*

**Deprecated** — use the `spaceReputation`
object instead. The flat form of `spaceReputation.spaceId`.
Still accepted (the object wins if both are passed); removal is a later
major version. Accepts a space `<uuid>`, `"none"`, or
`"context"`.

**spaceReputationDescendants** `boolean` *deprecated*

**Deprecated** — use
`spaceReputation.includeDescendants` instead. The flat form,
only honored alongside an explicit `spaceReputationId` `<uuid>`.

**Returns** — `Promise<{ answer: string; sources?: Array<{ entityId: string; title: string | null }> }>`

***

### matchUsers

Matches people by **activity-derived interest facets**, in `passive` mode (against a given user's own facets) or `directed` mode (against a free-text topic). See the [Interest Matching](https://docs.sublay.io/v7/interest-matching.md) guide for setup and the model.

> [!NOTE]
>
> Requires a paid plan, the `ai-search` and `interest-matching` bundles, and `interestMatching.enabled` on the project.

```typescript theme={null}
const { results } = await sublay.search.matchUsers({
  mode: "directed",
  query: "biotech",
  limit: 10,
});

// results: [{ user, score, matchedFacets: [{ similarity, candidateFacet, askerFacet?, sampleContent? }] }]
```

**mode** `string` *required*

`"passive"` or `"directed"`.

**query** `string`

The topic to match against. Required in `directed` mode; rejected in `passive` mode.

**limit** `number` (default: 20)

Maximum number of matched users. Maximum `50`.

**spaceId** `string`

Restrict candidates to users active in this space.

**includeChildSpaces** `boolean` (default: false)

With `spaceId`, also include users active in the space's subtree.

**includeSampleContent** `boolean` (default: false)

Request illustrative sample content per matched facet. Only honored when the project has `interestMatching.exposeSampleContent` on; otherwise returns `403 match/sample-content-disabled`.

**excludeSelf** `boolean` (default: true)

Exclude the asker from results.

**Returns** — `Promise<{ results: UserMatchResult[] }>` (the `{ results }` envelope, ordered by descending `score`).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.