-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
chore: Update the Vendure ElasticSearch plugin to use ElasticSearch v9.1.0 #3740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: minor
Are you sure you want to change the base?
chore: Update the Vendure ElasticSearch plugin to use ElasticSearch v9.1.0 #3740
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe updates upgrade Elasticsearch dependencies and configurations from version 7.x to 9.1.0 across GitHub Actions workflows, Docker Compose files, and templates. Corresponding code changes adapt to the new Elasticsearch client API, particularly the Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application Code
participant ESClient as Elasticsearch JS Client (v9.1.0)
participant ES as Elasticsearch Server
App->>ESClient: search(params, { meta: true })
ESClient->>ES: HTTP request (search)
ES-->>ESClient: HTTP response (body + metadata)
ESClient-->>App: { body, meta }
App->>App: Access response.body safely
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/elasticsearch-plugin/src/elasticsearch.service.ts (1)
596-600
: Improved method signature formatting for better readability.The method signature reformatting with proper parameter alignment enhances code readability without changing functionality.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
.github/workflows/build_and_test.yml
(1 hunks)docker-compose.yml
(1 hunks)packages/create/templates/docker-compose.hbs
(1 hunks)packages/elasticsearch-plugin/e2e/e2e-helpers.ts
(1 hunks)packages/elasticsearch-plugin/package.json
(1 hunks)packages/elasticsearch-plugin/src/elasticsearch.service.ts
(13 hunks)packages/elasticsearch-plugin/src/indexing/indexer.controller.ts
(6 hunks)packages/elasticsearch-plugin/src/indexing/indexing-utils.ts
(5 hunks)packages/elasticsearch-plugin/src/plugin.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/elasticsearch-plugin/src/indexing/indexer.controller.ts (1)
packages/elasticsearch-plugin/src/indexing/indexing-utils.ts (1)
getIndexNameByAlias
(144-155)
🔇 Additional comments (18)
packages/elasticsearch-plugin/package.json (1)
28-28
: Elasticsearch client dependency verified: @elastic/elasticsearch@9.1.0 is current and secure
- Confirmed 9.1.0 is the latest published version of the Node.js client
- No known security vulnerabilities reported for the 9.x series (per npm, Elastic release notes, Snyk)
No further changes needed—this upgrade is safe. Continue to monitor Elastic’s official security announcements for future advisories.
packages/elasticsearch-plugin/e2e/e2e-helpers.ts (1)
79-79
: LGTM! Improved test reliability.Adding
.sort()
makes the test order-insensitive, which is appropriate when upgrading Elasticsearch versions as search result ordering may differ between versions. This improves test stability..github/workflows/build_and_test.yml (1)
109-116
: Elasticsearch upgrade and security configuration look correct.The upgrade to Elasticsearch 9.1.0 and the added environment variables appropriately disable security features for CI/testing. The configuration includes:
- Security features disabled (appropriate for testing)
- Basic license type (suitable for development)
- Explicit node and cluster naming
Note: Ensure production deployments use appropriate security configurations instead of disabling these features.
docker-compose.yml (1)
82-94
: Elasticsearch configuration updated correctly for development.The upgrade to 9.1.0 with expanded environment variables is appropriate for local development. Key improvements:
- Memory limit prevents resource exhaustion
- Security features disabled (suitable for local dev)
- Consistent configuration with CI environment
Important: Ensure production deployments use proper security configurations instead of the disabled settings used here.
packages/create/templates/docker-compose.hbs (2)
99-99
: Port mapping correction looks good.The port mapping has been corrected from
9300:9200
to9200:9200
, which properly exposes the Elasticsearch HTTP API port.
79-91
: Elasticsearch configuration updated appropriately.The upgrade to 9.1.0 with comprehensive environment configuration is well-structured. The security features are appropriately disabled for development templates.
packages/elasticsearch-plugin/src/plugin.ts (1)
66-84
: Excellent documentation update for ElasticSearch v9.1.0 compatibility.The updated documentation clearly communicates the version upgrade and provides essential information about:
- Version compatibility requirements across all components
- Important security changes introduced in ElasticSearch v8+
- Configuration guidance for development vs production environments
- Reference to updated Docker Compose examples
This comprehensive documentation will help users understand the breaking changes and configure their environments correctly.
packages/elasticsearch-plugin/src/indexing/indexing-utils.ts (4)
73-76
: Correct API adaptation for Elasticsearch client v9.1.0.The changes properly remove the deprecated
body
wrapper and placemappings
andsettings
at the top level of the request parameters, aligning with the updated Elasticsearch client API format.Also applies to: 86-89
107-110
: Good addition of safety checks before index deletion.The conditional check ensures that the index name is valid before attempting deletion, which prevents potential errors and improves robustness.
121-123
: Consistent API update for deleteByQuery operation.The
query
parameter is correctly moved to the top level, maintaining consistency with other Elasticsearch client API updates throughout the codebase.
145-152
: Proper handling of new response format with metadata.The addition of
{ meta: true }
and the updated response handling correctly adapt to the new Elasticsearch client response structure. The safe property access with optional chaining is well implemented.packages/elasticsearch-plugin/src/indexing/indexer.controller.ts (3)
379-421
: Comprehensive API updates with improved error handling.The
updateByQuery
calls are correctly updated to use the new Elasticsearch client signature with{ meta: true }
. The enhanced error handling with conditional checks forresult.body.failures
and proper array iteration is a significant improvement that prevents potential runtime errors.
430-502
: Robust alias switching logic with enhanced safety guards.The
switchAlias
method is thoroughly updated with:
- Proper use of
{ meta: true }
for all index operations- Additional guards before deletion operations
- Consistent handling of the new response format
- Safe property access patterns throughout
The enhanced safety checks reduce the risk of errors during index operations.
861-868
: Correct bulk operation API adaptation.The bulk operation is properly updated to use the new client signature, spreading the request parameters and including
{ meta: true }
for consistent metadata handling.packages/elasticsearch-plugin/src/elasticsearch.service.ts (4)
72-73
: Correct ping operation update for new client API.The ping call is properly updated with
{ meta: true }
while maintaining the existing timeout configuration and response handling logic.
98-98
: Comprehensive indices operations updates with safe property access.The index existence checks and settings retrieval operations are correctly updated to use
{ meta: true }
. The safe property access patterns with optional chaining and conditional checks prevent potential runtime errors when accessing nested response properties.Also applies to: 111-121
221-227
: Consistent search API updates with proper request spreading.Both search operations correctly spread the elasticsearch body into the first argument and pass
{ meta: true }
as the second parameter, maintaining consistency with the new client API while preserving all existing functionality.Also applies to: 258-264
315-321
: Proper totalHits aggregation query update.The aggregation query is correctly updated with the new API format, and the response handling properly accesses the aggregation results from the updated response structure.
|
Bump: plan to merge this anytime soon? |
Hi @LeftoversTodayAppAdmin could you make this PR against the |
@michaelbromley Done! |
Description
Vendure has had a limitation on the version of ElasticSearch that can be used because of a licensing issue in v7.11 which has since been resolved. Therefore we can now use v9.1.0 as long as the plugin and the Vendure project use the new ES deployment and matching library.
Breaking changes
Does this PR include any breaking changes we should be aware of?
YES - Breaking change - ElasticSearch must be updated to v9.1.0, using the new client and plugin with the older v7 version of ES will FAIL.
Upgrading ElasticSearch is a one-way process, migrating the DB schema from v7.10.2 to v9.1.0 with no option to downgrade.
The ES instance and the client library in both the plugin and Vendure project package.json must match the upgraded ES instance version (v9.1.0).
Screenshots
You can add screenshots here if applicable.
Checklist
📌 Always:
👍 Most of the time:
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Refactor