Elasticsearch
Elasticsearch search plugin for Medusa v2
Medusa Elasticsearch Plugin
Elasticsearch search plugin for Medusa v2. Provides automatic product and category indexing, full-text search, and admin sync capabilities powered by Elasticsearch.
Features
- Product and category indexing with real-time sync on create, update, and delete events
- Full reindex via admin API endpoint or scheduled job (daily at midnight)
- Batch syncing with pagination (50 items per batch) for large catalogs
- Smart filtering -- only published products and active/non-internal categories are indexed
- Custom document transformers per index type
- Configurable Elasticsearch mappings, analyzers, and tokenizers
- Search API for products () and categories ()
- Admin API at with authentication
- Admin UI settings page at with sync button and search testing
- Workflow compensation -- automatic rollback on indexing failures
- Built as a Medusa v2 module with workflows, subscribers, and scheduled jobs
Prerequisites
- Medusa v2 application (v2.5.0+)
- Elasticsearch 9.x instance or Elastic Cloud
Installation
1. Install the plugin in your Medusa project:
2. Set environment variables in :
Or for a local Elasticsearch 9.x instance:
3. Register the plugin and module in :
Options
Module Options
| Name | Description | Required |
|---|---|---|
| Elasticsearch client configuration (cloud, auth, node, etc.) | true | |
| Index configurations keyed by index name (, , or custom) | false |
Index Options (per index in )
| Name | Description | Required |
|---|---|---|
| Custom document transformer function | false | |
| Elasticsearch mapping configuration | false | |
| Elasticsearch index settings (analyzers, tokenizers, normalizers) | false |
API Endpoints
Store: Search Products
POST /store/products/searchSearch products indexed in Elasticsearch. No authentication required.
Request body:
Store: Search Categories
POST /store/categories/searchSearch product categories. No authentication required.
Request body:
Response: Standard Elasticsearch search response with .
Admin: Trigger Full Sync
POST /admin/elasticsearch/syncTriggers a full reindex of all products and categories. Requires admin authentication (session, bearer, or API key).
Response:
The sync runs asynchronously, processing items in batches of 50.
Automatic Syncing
Real-time Events
The plugin automatically syncs on these events:
Products:
- -- indexes the new product
- -- re-indexes the updated product
- -- removes the product from the index
Categories:
- -- indexes the new category
- -- re-indexes the updated category
- -- removes the category from the index
Indexing Rules
- Products: Only products are indexed. Draft/unpublished products are removed from the index.
- Categories: Only and categories are indexed. Inactive or internal categories are removed.
Scheduled Reindex
A scheduled job runs daily at midnight to trigger a full reindex via the event.
Manual Reindex
Use the admin API endpoint or emit the event directly:
Workflows
The plugin exports workflows for direct use:
Custom Transformer
By default, products are indexed with a built-in transformer that flattens variant data, tags, categories, and collections. Categories are indexed with parent/children metadata. You can override either:
Architecture
Roadmap
Planned features for future releases:
- i18n / multi-language support -- index per locale or field-suffix strategy for multilingual storefronts
-
Admin UI extension -- dashboard widget with sync button, index status, and document counts - Configurable reindex schedule -- allow custom cron expressions via module options
- Collection indexing -- sync product collections alongside products and categories
- Aggregation helpers -- pre-built faceted search support (price ranges, categories, tags)
- Geo-search support -- location-based product search leveraging Elasticsearch's geo queries
- Index aliasing -- zero-downtime reindexing using Elasticsearch index aliases
- Bulk reindex CLI command -- one-time full reindex via Medusa CLI
Additional Resources
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
License
MIT

