A Vendure plugin for managing Elasticsearch synonym sets from the admin UI. Synonym groups are stored in the database, synced to Elasticsearch on startup and on every change, and applied at search time via the Elasticsearch Synonyms API (Elasticsearch 9.x).
synonym_filter, synonym_analyzer, and example field mappingsAdd the plugin to your Vendure configuration and wire your Elasticsearch index to use the synonyms set (see Elasticsearch index config).
Open Settings → Synonyms in the dashboard to manage synonym sets.
| Option | Type | Default | Description |
|---|---|---|---|
channelSpecificSynonyms | boolean | false | When true, syncs each channel's synonym groups to a separate Elasticsearch synonyms set |
synonymsSetIdPattern | string | vendure-synonyms-{channelToken} | Pattern for per-channel set ids. Placeholders: {channelToken}, {channelId}, {channelCode} |
synonymsSetId | string | vendure-synonyms | Global Elasticsearch synonyms set id when channelSpecificSynonyms is false |
maxGroupBytes | number | 16000 | Max UTF-8 size of one synonym group line synced to Elasticsearch |
maxTokenLength | number | 128 | Max characters per individual term |
maxTokensPerGroup | number | 128 | Max number of terms per group |
Used by the plugin when syncing synonym rules to Elasticsearch.
| Variable | Default | Description |
|---|---|---|
ELASTICSEARCH_HOST | http://localhost | Elasticsearch host URL (scheme + host, no port), e.g. https://es.example.com |
ELASTICSEARCH_PORT | 9200 | Elasticsearch port (appended to ELASTICSEARCH_HOST) |
ELASTICSEARCH_SYNONYMS_SET | vendure-synonyms | Overrides default synonyms set id (same as synonymsSetId when unset) |
A synonym set is a group of words or phrases that mean the same thing for search purposes. Elasticsearch treats every term in the set as interchangeable when a customer runs a query.
Example set: tv, television, flatscreen
| Customer searches for | Can match products indexed with |
|---|---|
tv | television, flatscreen |
television | tv, flatscreen |
flatscreen | tv, television |
The relationship works both ways within a set: any term can match any other term in the same group.
What changes in the index
"LED television").search_analyzer, not when documents are indexed.search_analyzer to synonym_analyzer on each field where queries should expand synonyms (the helpers include examples for productName and productDescription).synonym filter with synonyms_set and updateable: true on the search analyzer pick up rule changes without reindexing.When channelSpecificSynonyms: true:
vendure-synonyms-{channelToken} (e.g. vendure-synonyms-eu-store).When channelSpecificSynonyms: false (default):
synonymsSetId, default vendure-synonyms).languageCode on each group is for organization in the admin UI only.The plugin manages synonym rules, stores synonym sets in the database and syncs them to Elasticsearch. You still need to wire those rules into your index: configure filters, analyzers, and field mappings in your Elasticsearch config so search queries use the synonyms set.
For a quick start, use the exported helpers and default index settings below with ElasticsearchPlugin.init(). If you prefer full control over analyzers, filters, and mappings, define your own configuration instead; see Manual config example.
| Export | Use in | What it provides |
|---|---|---|
defaultSynonymFilters | indexSettings.analysis.filter | Defines synonym_filter: a synonym token filter pointing at the default set id (vendure-synonyms) with updateable: true, so Elasticsearch reloads synonyms when the set changes. |
createSynonymFilter(id?) | indexSettings.analysis.filter | Same as defaultSynonymFilters, but lets you pass a custom synonyms set id (global mode). |
createChannelSynonymFilter(channel) | per-channel index settings | Builds a filter for one channel using synonymsSetIdPattern (channel-specific mode). |
createChannelSynonymAnalyzer() | per-channel index settings | Analyzer that applies a channel-specific synonym filter at query time. |
resolveSynonymsSetId(pattern, channel) | — | Resolves the Elasticsearch synonyms set id for a channel, e.g. vendure-synonyms-eu-store. |
DEFAULT_SYNONYMS_SET_ID_PATTERN | — | Default pattern 'vendure-synonyms-{channelToken}'. |
defaultSynonymAnalyzer | indexSettings.analysis.analyzer | Defines synonym_analyzer: standard tokenizer, lowercase, then synonym_filter. Use only as search_analyzer on fields, not for indexing. |
defaultSynonymIndexMappingProperties | indexMappingProperties | Starter mappings for productName and productDescription with search_analyzer: synonym_analyzer (and a keyword subfield on productName). |
DEFAULT_SYNONYMS_SET_ID | — | Constant 'vendure-synonyms'—default id for the Elasticsearch synonyms set and for createSynonymFilter(). |
SYNONYM_FILTER_NAME | — | Constant 'synonym_filter'—filter name used inside defaultSynonymAnalyzer. |
SYNONYM_ANALYZER_NAME | — | Constant 'synonym_analyzer'—reference this as search_analyzer on any field that should expand synonyms at query time. |
Vendure creates one Elasticsearch index per channel. When channelSpecificSynonyms: true, each index must point at the synonyms set for that channel. Use resolveSynonymsSetId() (or the createChannelSynonymFilter() helper) with the channel token when building index settings.
If your ElasticsearchPlugin setup supports customizing index settings per channel, configure each channel index like this:
If your Elasticsearch setup uses a static indexSettings object (same for all channels), use channel-specific synonyms only when each channel has its own Vendure server/database, or extend index creation so each channel index gets the matching synonyms_set id.