Skip to content

task(34647) ContentletFactory migration to OS - ESContentletScroll API #34742

Merged
fabrizzio-dotCMS merged 28 commits intomainfrom
issue-34647-OSContentScroll
Feb 26, 2026
Merged

task(34647) ContentletFactory migration to OS - ESContentletScroll API #34742
fabrizzio-dotCMS merged 28 commits intomainfrom
issue-34647-OSContentScroll

Conversation

@fabrizzio-dotCMS
Copy link
Contributor

@fabrizzio-dotCMS fabrizzio-dotCMS commented Feb 23, 2026

Proposed Changes

This PR implements the separation and abstraction of ESContentletScrollImpl to enable OpenSearch migration while maintaining backwards compatibility with the existing ElasticSearch implementation.

Key Changes:

  • ✅ Created IndexContentletScroll interface - Common abstraction for both ElasticSearch and OpenSearch scroll implementations
  • ✅ Extracted ESContentletScrollImpl - ElasticSearch-specific implementation maintaining existing functionality
  • ✅ Added OSContentletScrollImpl - New OpenSearch implementation with equivalent scroll API functionality
  • ✅ Updated ContentletFactory and related classes - Modified to use the new abstraction layer

Architecture Improvements

Before: Tightly Coupled Implementation

// Direct ES implementation in ContentletFactory
ESContentletScrollImpl scroll = new ESContentletScrollImpl(query, user, respectFrontendRoles, batchSize, sortBy);

After: Clean Abstraction Layer

// Factory method returns abstracted interface
IndexContentletScroll scroll = createScrollQuery(query, user, respectFrontendRoles, batchSize, sortBy);
// Implementation is determined at runtime based on configured search engine

Technical Details

New Interface: IndexContentletScroll

  • Defines standard contract for scroll-based queries
  • Supports both ElasticSearch and OpenSearch implementations
  • Provides consistent API: nextBatch(), getTotalHits(), hasMoreResults(), close()
  • Implements AutoCloseable for proper resource management

ElasticSearch Implementation (ESContentletScrollImpl)

  • Made package-private - No longer exposed as public API
  • Maintains all existing functionality - Zero behavioral changes
  • Uses existing ElasticSearch client and search operations
  • Preserves current configuration properties (ES_SCROLL_*)

OpenSearch Implementation (OSContentletScrollImpl)

  • New OpenSearch-native implementation using OpenSearch Java client
  • Equivalent functionality to ES implementation with OpenSearch API calls
  • Uses OpenSearch-specific configuration properties (OS_SCROLL_*)
  • Handles OpenSearch query translation and response processing

Migration Benefits

  1. Zero Breaking Changes - Existing code continues to work unchanged
  2. Runtime Engine Selection - Search engine determined by configuration
  3. Consistent API - Same interface regardless of underlying engine
  4. Isolated Implementations - ES and OS code separated and independently maintainable
  5. Future-Proof Architecture - Easy to add additional search engines

I'll introduce the proper testing for this new impl when other relevant parts of the index mapping mechanism are in place.

This PR fixes: #34647

This PR fixes: #34647

@fabrizzio-dotCMS fabrizzio-dotCMS marked this pull request as ready for review February 25, 2026 20:52
Copy link
Contributor

@dsolistorres dsolistorres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good set of changes, including the implementation for OpenSearch scrolling and the refactor to use a common abstraction for both OpenSearch and ElasticSearch

@fabrizzio-dotCMS fabrizzio-dotCMS added this pull request to the merge queue Feb 26, 2026
Merged via the queue into main with commit 50c837a Feb 26, 2026
39 checks passed
@fabrizzio-dotCMS fabrizzio-dotCMS deleted the issue-34647-OSContentScroll branch February 26, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[TASK] Migrate ESContentFactoryImpl

3 participants