Purpose
Document the feasibility and plan for migrating from Elasticsearch 8.x to OpenSearch 2.x. This migration would reduce licensing concerns and costs while maintaining feature parity.Current State
Elasticsearch Usage in Codebase
Current Client
- Package:
@elastic/elasticsearchv8.x - Connection: Via
ElasticsearchServicefrom@nestjs/elasticsearch
Compatibility Assessment
What Works the Same
What Requires Changes
Migration Steps
Phase 1: Client Swap (Day 1)
-
Install OpenSearch client
-
Create OpenSearch module wrapper
- Create
opensearch.module.tsto replaceElasticsearchModule - Maintain same service interface
- Create
-
Update imports across codebase
- Find/replace
ElasticsearchServicereferences
- Find/replace
Phase 2: Vector Search Migration (Day 1-2)
-
Update index mappings for vector fields
Before (Elasticsearch):
After (OpenSearch):
-
Update KNN query syntax
Before (Elasticsearch 8.x):
After (OpenSearch):
- Reindex data with new mappings
Phase 3: Testing & Validation (Day 2-3)
- Unit tests - Verify all search functions work
- Integration tests - Test against OpenSearch instance
- Performance comparison - Benchmark KNN search latency
- Data validation - Ensure search results quality unchanged
Phase 4: Deployment
- Set up OpenSearch cluster (or use managed service)
- Migrate data from Elasticsearch
- Update environment configurations
- Deploy updated application
- Monitor for issues