> ## 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

export const SpaceReputationParams = ({variant = "context", field = "path"}) => {
  const isUser = variant === "user";
  return <>
      <ParamField {...{
    [field]: "spaceReputation",
    type: "object"
  }}>
        Opt-in. Adds a <code>spaceReputation</code> number to each returned user,
        scoped to a single space. Requires the <code>reputation</code> bundle.
        The <code>reputation</code> total is always present regardless;{" "}
        <code>spaceReputation</code> is purely additive and only appears when you
        pass this object. <strong>This object is the primary form</strong> — it
        replaces the deprecated flat props below. See the{" "}
        <a href="/v8/data-models/reputation">Reputation data model</a> for the
        full contract.

        <Expandable title="spaceReputation">
          {isUser ? <ParamField name="spaceId" type="string | &quot;none&quot;" required>
              Which bucket to read. A space <strong><code>&lt;uuid&gt;</code></strong> reads that
              space's bucket; <strong><code>"none"</code></strong> reads the
              project-general (space-less) bucket.{" "}
              <strong><code>"context"</code> is rejected (400)</strong> on this
              endpoint — there is no space context to derive. The empty string
              and the legacy <code>general</code> / <code>null</code> aliases are
              also rejected. Missing buckets read as <code>0</code>.
            </ParamField> : <ParamField name="spaceId" type="string | &quot;none&quot; | &quot;context&quot;" required>
              Which bucket to read. One of: a space <strong><code>&lt;uuid&gt;</code></strong>{" "}
              (that space's bucket), <strong><code>"none"</code></strong> (the
              project-general, space-less bucket), or{" "}
              <strong><code>"context"</code></strong> (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{" "}
              <code>general</code> / <code>null</code> aliases are rejected (400).
              Missing buckets read as <code>0</code>.
            </ParamField>}
          <ParamField name="includeDescendants" type="boolean">
            Only honored when <code>spaceId</code> is an explicit space <code>&lt;uuid&gt;</code>.
            When <code>true</code>, <code>spaceReputation</code> is the{" "}
            <strong>subtree sum</strong> — the named space plus all of its
            descendant spaces (the root space's own bucket included). Ignored for{" "}
            <code>"none"</code>; not allowed with <code>"context"</code>.
          </ParamField>
        </Expandable>
      </ParamField>

      {isUser ? <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code> or <code>"none"</code> only —{" "}
          <code>"context"</code> is rejected (400) on this endpoint.
        </ParamField> : <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code>, <code>"none"</code>, or{" "}
          <code>"context"</code>.
        </ParamField>}

      <ParamField {...{
    [field]: "spaceReputationDescendants",
    type: "boolean",
    deprecated: true
  }}>
        <strong>Deprecated</strong> — use{" "}
        <code>spaceReputation.includeDescendants</code> instead. The flat form,
        only honored alongside an explicit <code>spaceReputationId</code> <code>&lt;uuid&gt;</code>.
      </ParamField>
    </>;
};

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,
});
```

<ParamField body="query" type="string" required>
  The search query string.
</ParamField>

<ParamField body="sourceTypes" type="string[]">
  Which content types to search: any of `"entity"`, `"comment"`, `"message"`.
</ParamField>

<ParamField body="spaceId" type="string">
  Scope the search to a specific space.
</ParamField>

<ParamField body="includeChildSpaces" type="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`.
</ParamField>

<ParamField body="conversationId" type="string">
  Scope the search to a specific conversation.
</ParamField>

<ParamField body="limit" type="number">
  Maximum number of results to return.
</ParamField>

<SpaceReputationParams variant="context" field="body" />

**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,
});
```

<ParamField body="query" type="string" required>
  The search query string.
</ParamField>

<ParamField body="limit" type="number">
  Maximum number of results to return.
</ParamField>

**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,
});
```

<ParamField body="query" type="string" required>
  The search query string.
</ParamField>

<ParamField body="limit" type="number">
  Maximum number of results to return.
</ParamField>

**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](/v8/semantic-search-ai) guide for setup instructions.
</Note>

```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" }, ...]
```

<ParamField body="query" type="string" required>
  The natural-language question to answer.
</ParamField>

<ParamField body="sourceTypes" type="string[]">
  Which content types to draw from: any of `"entity"`, `"comment"`, `"message"`.
</ParamField>

<ParamField body="spaceId" type="string">
  Scope the search to content within a specific space.
</ParamField>

<ParamField body="includeChildSpaces" type="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`.
</ParamField>

<ParamField body="conversationId" type="string">
  Scope the search to a specific conversation.
</ParamField>

<ParamField body="limit" type="number">
  Maximum number of sources to draw from.
</ParamField>

<SpaceReputationParams variant="context" field="body" />

**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](/v8/interest-matching) guide for setup and the model.

<Note>
  Requires a paid plan, the `ai-search` and `interest-matching` bundles, and `interestMatching.enabled` on the project.
</Note>

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

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

<ParamField body="mode" type="string" required>
  `"passive"` or `"directed"`.
</ParamField>

<ParamField body="query" type="string">
  The topic to match against. Required in `directed` mode; rejected in `passive` mode.
</ParamField>

<ParamField body="limit" type="number" default="20">
  Maximum number of matched users. Maximum `50`.
</ParamField>

<ParamField body="spaceId" type="string">
  Restrict candidates to users active in this space.
</ParamField>

<ParamField body="includeChildSpaces" type="boolean" default="false">
  With `spaceId`, also include users active in the space's subtree.
</ParamField>

<ParamField body="includeSampleContent" type="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`.
</ParamField>

<ParamField body="excludeSelf" type="boolean" default="true">
  Exclude the asker from results.
</ParamField>

**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.