@hyperse-hub/hps-plugin-typesense
Vendure search plugin that indexes catalog data into Typesense and serves shop and admin search through the standard search GraphQL APIs. It is intended as a drop-in replacement for DefaultSearchPlugin (or similar search backends): product and variant updates are reflected in the index via domain events, with optional buffering for heavy workloads.
The design and configuration surface are heavily inspired by Vendure’s Elasticsearch plugin. Thanks to that work for establishing the patterns used here.
Requirements
- Node.js ≥ 20
- Vendure ≥ 3.0 (see plugin
compatibility in code)
- A running Typesense server reachable from the Vendure API process
Installation
- Remove any other product search plugin from
VendureConfig.plugins (for example DefaultSearchPlugin, ElasticSearchPlugin, or another Typesense-backed plugin).
- Register
HpsPluginTypesense and call .init() with your connection and options.
import { HpsPluginTypesense } from '@hyperse-hub/hps-plugin-typesense';
import type { VendureConfig } from '@vendure/core';
const config: VendureConfig = {
plugins: [
HpsPluginTypesense.init({
apiKey: process.env.TYPESENSE_API_KEY ?? 'xyz',
host: 'http://localhost',
port: 8108,
}),
],
};
Default connection values match local development: host http://localhost, port 8108, apiKey xyz. Override these for production.
Advanced client configuration
You can pass a Typesense JS client configuration with clientOptions (for example multiple nodes or TLS). If clientOptions.nodes is set, it overrides host and port.
Features
- Indexing: Creates collections with a configurable
indexPrefix (default vendure-), applies indexSettings and optional indexMappingProperties for schema tuning.
- Incremental updates: Listens to product, variant, asset, channel, collection, and tax events; debounces collection-driven variant updates.
- Reindexing: Chunked full reindex with
reindexChunkSize and reindexChunkOperationSize.
- Search: Extends
SearchInput with priceRange, priceRangeWithTax, and inStock-style filtering as implemented in the plugin. searchConfig controls facets, hit limits, field boosts, extra Typesense query params, and optional mapQuery for custom term shaping.
- Custom mappings:
customProductMappings and customProductVariantMappings add fields to the index and expose them on SearchResult (including GraphQL union customMappings when both kinds exist). Use hydrateProductRelations / hydrateProductVariantRelations so valueFn receives loaded relations.
- Buffered updates: Set
bufferUpdates: true to defer index writes until runPendingSearchIndexUpdates (Admin API), similar to Vendure’s buffered search pattern.
- GraphQL extensions:
extendSearchInputType and extendSearchSortType add custom fields to search input and sort parameters. Extended input values can be read inside searchConfig.mapQuery when you build the Typesense query string.
- Health: Registers a health indicator when Typesense is reachable on bootstrap.
Full option list and defaults are documented in TypeScript on HpsPluginTypesenseOptions in the package source (src/typesense/options.ts).
Local development
From this package directory:
yarn install
yarn build
yarn serve
yarn serve loads config/dev-server.ts (with config/.env if present) and starts a dev Vendure instance with HpsPluginTypesense.init({}).
License
MIT — see the repository LICENSE where applicable.