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.
Extends
Section titled “Extends”GenericQueryServerParams<DataModel,TCollectionSlug,TPopulate,D>
Type Parameters
Section titled “Type Parameters”DataModel
Section titled “DataModel”DataModel extends GenericDataModel
The Convex data model (inferred from ctx).
TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends CollectionSlug
Collection slug.
TPopulate
Section titled “TPopulate”TPopulate extends PopulateShape<TCollectionSlug>
Populate object.
D extends number = 0
Depth literal (0 = no depth, default).
Properties
Section titled “Properties”access?
Section titled “access?”
optionalaccess?:AccessCallOptions<QueryCallAction>
Defined in: packages/core/src/collections/api/types.ts:143
Per-call access overrides.
Inherited from
Section titled “Inherited from”GenericQueryServerParams.access
optionalauth?:VexApiAuth
Defined in: packages/core/src/collections/api/types.ts:150
The auth config of the current user making the query.
Example
Section titled “Example”{ user: {...}, organization: {...} }Inherited from
Section titled “Inherited from”collection
Section titled “collection”collection:
TCollectionSlug
Defined in: packages/core/src/collections/api/search/server.ts:68
The collection to search — must match a registered collection slug.
config?
Section titled “config?”
optionalconfig?: [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.
Inherited from
Section titled “Inherited from”GenericQueryServerParams.config
ctx:
GenericQueryCtx<DataModel>
Defined in: packages/core/src/collections/api/types.ts:152
Discriminator: server args MUST supply a Convex query context.
Inherited from
Section titled “Inherited from”depth?
Section titled “depth?”
optionaldepth?: [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.
Inherited from
Section titled “Inherited from”GenericQueryServerParams.depth
drafts?
Section titled “drafts?”
optionaldrafts?:boolean
Defined in: packages/core/src/collections/api/search/server.ts:120
Same contract as FindServerArgs.drafts — see find/server.ts.
limit?
Section titled “limit?”
optionallimit?: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.
paginationOpts?
Section titled “paginationOpts?”
optionalpaginationOpts?: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.
populate?
Section titled “populate?”
optionalpopulate?: [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.
Inherited from
Section titled “Inherited from”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
Section titled “searchField”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
Section titled “searchIndexName”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").
optionalsort?: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.
where?
Section titled “where?”
optionalwhere?: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.
Example
Section titled “Example”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 } })