Configuration for an external index, which is a Typesense collection for non-Product data.

interface ExternalIndexConfig<T> {
    createDocuments: ((ctx: RequestContext, injector: Injector, ids: ID[]) => Promise<T[]>);
    createTypesenseSearchParams: ((ctx: RequestContext, injector: Injector, input: ExternalSearchScopedInput) => TypesenseSearchParams<T> | Promise<TypesenseSearchParams<T>>);
    fields: ExternalIndexDefinition<T>;
    getAllIds: ((injector: Injector) => Promise<ID[]>);
    name: string;
    queryName?: string;
    removeStream: ((injector: Injector) => Observable<ID[]> | Promise<Observable<ID[]>>);
    updateStream: ((injector: Injector) => Observable<ID[]> | Promise<Observable<ID[]>>);
}

Type Parameters

Properties

createDocuments: ((ctx: RequestContext, injector: Injector, ids: ID[]) => Promise<T[]>)

A function which defines how a search document is created based on the document IDs. The IDs from the getAllIds & updateStream methods are passed to this function to create the documents which will be stored in the Typesense collection.

createTypesenseSearchParams: ((ctx: RequestContext, injector: Injector, input: ExternalSearchScopedInput) => TypesenseSearchParams<T> | Promise<TypesenseSearchParams<T>>)

A function which creates the search parameters for a given search input. This will be called whenever a search is performed on this index.

fields: ExternalIndexDefinition<T>

The definition of the fields in the index.

getAllIds: ((injector: Injector) => Promise<ID[]>)

A function which returns the IDs of all the documents in the index. This is used when running a full reindex.

name: string

The name of the index as it will appear in Typesense. This name is also used as the basis for dynamically generating types in the GraphQL schema.

queryName?: string

By default, the plugin will generate a new query for each index named search${indexName}. If you want to override this behaviour (for example if the default name would clash with an existing query), you can specify a custom query name here.

1.6.0

removeStream: ((injector: Injector) => Observable<ID[]> | Promise<Observable<ID[]>>)

A function which returns an Observable which emits the IDs of all the documents which have been removed. These IDs are then used to remove the documents from the index.

updateStream: ((injector: Injector) => Observable<ID[]> | Promise<Observable<ID[]>>)

A function which returns an Observable which emits the IDs of all the documents which have been updated. These IDs are then used to fetch the updated documents and reindex them.