Skip to content

SearchServerArgs

Defined in: packages/core/src/collections/api/search/server.ts:61

Server-side args for search.

Inherits ctx, populate, depth, and config (with mutual-exclusion constraints) from GenericQueryServerParams.

DataModel extends GenericDataModel

The Convex data model (inferred from ctx).

TCollectionSlug extends CollectionSlug

Collection slug.

TPopulate extends PopulateShape<TCollectionSlug>

Populate object.

D extends number = 0

Depth literal (0 = no depth, default).

optional access?: AccessCallOptions<QueryCallAction>

Defined in: packages/core/src/collections/api/types.ts:143

Per-call access overrides.

AccessCallOptions

GenericQueryServerParams.access


optional auth?: VexApiAuth

Defined in: packages/core/src/collections/api/types.ts:150

The auth config of the current user making the query.

{ user: {...}, organization: {...} }

GenericQueryServerParams.auth


collection: TCollectionSlug

Defined in: packages/core/src/collections/api/search/server.ts:68

The collection to search — must match a registered collection slug.


optional config?: [TPopulate] extends [Record<string, never>] ? VexConfig : never

Defined in: packages/core/src/collections/api/types.ts:168

The resolved VexConfig. Required alongside depth; passed from the queryApi factory closure so the Convex handler has schema info.

GenericQueryServerParams.config


ctx: GenericQueryCtx<DataModel>

Defined in: packages/core/src/collections/api/types.ts:152

Discriminator: server args MUST supply a Convex query context.

GenericQueryServerParams.ctx


optional depth?: [TPopulate] extends [Record<string, never>] ? D : never

Defined in: packages/core/src/collections/api/types.ts:163

Auto-populate all relationship fields to this many levels. Becomes never when TPopulate is non-empty. Use populate for consumer-facing code; this is an internal escape hatch for CollectionListView.

GenericQueryServerParams.depth


optional drafts?: boolean

Defined in: packages/core/src/collections/api/search/server.ts:120

Same contract as FindServerArgs.drafts — see find/server.ts.


optional limit?: number

Defined in: packages/core/src/collections/api/search/server.ts:100

Maximum number of results, applied as the terminal .take(n). Omit it, or pass 0, to return every match (.collect()). Ignored when paginationOpts is set.


optional paginationOpts?: PaginationOptions

Defined in: packages/core/src/collections/api/search/server.ts:107

Pagination options. When provided, the function returns a PaginationResult with { page, continueCursor, isDone } instead of a plain array.

Uses Convex’s native .paginate(opts) API under the hood.


optional populate?: [D] extends [0] ? TPopulate : never

Defined in: packages/core/src/collections/api/types.ts:157

Recursive populate object, type-narrowed against RelationshipKeysOf<TCollectionSlug>. Mutually exclusive with depth — becomes never when D ≠ 0.

GenericQueryServerParams.populate


query: string

Defined in: packages/core/src/collections/api/search/server.ts:70

The search text. Pass "" to list recent documents (falls back to .take()).


searchField: string

Defined in: packages/core/src/collections/api/search/server.ts:83

The field the search index is built on. Must match searchField in the index declaration. When config is supplied, validated against the collection’s admin.view.state.searchFields allow-list — a field outside it throws a VexError naming the field and the declared list (Design Decision 2) — and against the caller’s field-read access, which throws a VexAccessError (Design Decision 26): search hits on a field the caller cannot read would leak its values just as much as a sortable column would.


searchIndexName: string

Defined in: packages/core/src/collections/api/search/server.ts:72

The .searchIndex() name declared in the Convex schema (e.g. "search_name").


optional sort?: undefined

Defined in: packages/core/src/collections/api/search/server.ts:94

Always absent on search — typed never so a caller building args from shared { sort, search, searchField } state gets a compile error if it forwards sort here. search also throws a VexError at runtime if one arrives anyway (Design Decision 7: search results are relevance-ordered, so sort and search are mutually exclusive). Clear sort before searching, or clear the search query to sort — find’s sort is the only route to a sorted read.


optional where?: VexWhere<TCollectionSlug>

Defined in: packages/core/src/collections/api/search/server.ts:118

Predicate over the collection’s fields, applied to the search results. Same builder as find’s where.

search({ ctx, collection: "posts", query: "hello", searchIndexName: "search_title", searchField: "title", where: (q) => q.eq("published", true) })
search({ ctx, collection: "posts", query: "hello", searchIndexName: "search_title", searchField: "title", where: { field: "published", op: "eq", value: true } })