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, comments and chat messages by meaning, optionally scoped to a space or conversation.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.The user to search as: the result is exactly what their own access token would get — their chats, their blocks, the comment moderation details they may see. Without it you get the anonymous view: no chat messages, no block filtering, no moderation details.
Promise<ContentSearchResult[]>, most similar first. Each result is { sourceType, similarity, record }, where record’s type follows sourceType: an Entity for "entity", a Comment for "comment", and for "message" a ContentSearchChatMessage — the stored chat message with its sender as user (a User, or null), without reactions, files, grants or the quoted message.
searchUsers
Searches for users by name or username.The user to search as: the results are exactly what their own access token would get, so users block-edged with them are left out. Omit to search with no viewer.
Promise<UserSearchResult[]>, most similar first: each is { similarity: number; record: User }.
searchSpaces
Searches for spaces by name or description.Promise<SpaceSearchResult[]>, most similar first: each is { similarity: number; record: Space }. Only public spaces are returned.
askContent
Asks a natural-language question about your content. The server streams the AI-generated answer as it is written, soaskContent is an async generator: iterate it with for await to read each event as it arrives.
This feature requires semantic search to be enabled for your project. See the Semantic Search & AI guide for setup instructions.
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.The user to search as: the result is exactly what their own access token would get — their chats, their blocks, the comment moderation details they may see. Without it you get the anonymous view: no chat messages, no block filtering, no moderation details.
Aborts the request and closes the stream; the
for await loop then throws a CanceledError (axios). Leaving the loop with break closes the stream too and ends quietly.AsyncGenerator<AskContentEvent>. The events, in order:
A request refused before the stream opens throws, like every other function, with the JSON error body on
err.response.data: for example 403 project/plan-required without a paid plan, or a 400 for an invalid body.
matchUsers
Matches people by activity-derived interest facets, for one user (actingUserId), in passive mode (against that user’s own facets) or directed mode (against a free-text topic). See the Interest Matching guide for setup and the model.
Requires a paid plan, the
ai-search and interest-matching bundles, and interestMatching.enabled on the project.The user to find matches for (the asker). Their interests drive
passive mode, users block-edged with them are left out, and the result is exactly what their own access token would get.The topic to match against. Required in
directed mode; not allowed in passive mode. TypeScript enforces both.Request illustrative sample content per matched facet. Only honored when the project has
interestMatching.exposeSampleContent on; otherwise returns 403 match/sample-content-disabled.Promise<{ results: UserMatchResult[] }> (the { results } envelope, ordered by descending score).
