feat: migrate registry to OpenSearch 2.19.5 from Elasticsearch 7.10.1#361
Open
chethann007 wants to merge 6 commits into
Open
feat: migrate registry to OpenSearch 2.19.5 from Elasticsearch 7.10.1#361chethann007 wants to merge 6 commits into
chethann007 wants to merge 6 commits into
Conversation
…nSearch compatibility
sntiwari1
approved these changes
May 6, 2026
There was a problem hiding this comment.
Pull request overview
This PR migrates the registry’s search integration from Elasticsearch 7.10.1 to OpenSearch 2.19.5 by updating Java client dependencies/imports, removing deprecated document-type usage, and aligning local Docker tooling to run OpenSearch 2.x.
Changes:
- Updated
elastic-searchmodule to use OpenSearch 2.19.5 clients/APIs and removed Elasticsearch document type usage. - Updated registry configuration/constants to stop passing
_doctype. - Updated Docker/Docker Compose artifacts to run OpenSearch 2.19.5 and adjust Java runtime base image(s).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| java/registry/src/main/java/dev/sunbirdrc/registry/config/GenericConfiguration.java | Removes setType(_doc) usage when wiring the elastic service bean. |
| java/registry/pom.xml | Adds/pins dependencies (httpcomponents/Jackson) and excludes OSGi httpcomponents bundles from the Spring Boot fat jar. |
| java/registry/docker-compose.yml | Switches local compose from Elasticsearch 7.10.1 to OpenSearch 2.19.5 and updates env vars accordingly. |
| java/middleware-commons/src/main/java/dev/sunbirdrc/registry/middleware/util/Constants.java | Removes ES_DOC_TYPE constant now that types are removed. |
| java/elastic-search/src/main/java/dev/sunbirdrc/elastic/IElasticService.java | Updates RestStatus import to OpenSearch. |
| java/elastic-search/src/main/java/dev/sunbirdrc/elastic/ElasticServiceImpl.java | Migrates client API usage to OpenSearch and removes document type handling. |
| java/elastic-search/pom.xml | Replaces Elasticsearch dependencies with OpenSearch 2.19.5 and pins related dependency versions; sets compiler target to Java 11. |
| java/Dockerfile | Updates Java base image to Java 11 JRE (Alpine). |
Comments suppressed due to low confidence (3)
java/elastic-search/src/main/java/dev/sunbirdrc/elastic/ElasticServiceImpl.java:189
- addEntity() can throw a NullPointerException when the index request fails: IOException is caught, but response remains null and response.status() is still returned. Return a safe RestStatus (e.g., INTERNAL_SERVER_ERROR) or rethrow so callers can handle the failure explicitly.
public RestStatus addEntity(String index, String entityId, JsonNode inputEntity) {
logger.debug("addEntity starts with index {} and entityId {}", index, entityId);
IndexResponse response = null;
try {
Map<String, Object> inputMap = JSONUtil.convertJsonNodeToMap(inputEntity);
response = getClient(index).index(new IndexRequest(index).id(entityId).source(inputMap), RequestOptions.DEFAULT);
} catch (IOException e) {
logger.error("Exception in adding record to ElasticSearch", e);
}
return response.status();
}
java/elastic-search/src/main/java/dev/sunbirdrc/elastic/ElasticServiceImpl.java:231
- updateEntity() can throw a NullPointerException when the update request fails: IOException is caught, but response remains null and response.status() is still returned. Return a safe RestStatus (e.g., INTERNAL_SERVER_ERROR) or propagate the exception so failures don’t become NPEs.
public RestStatus updateEntity(String index, String osid, JsonNode inputEntity) {
logger.debug("updateEntity starts with index {} and entityId {}", index, osid);
UpdateResponse response = null;
try {
Map<String, Object> inputMap = JSONUtil.convertJsonNodeToMap(inputEntity);
logger.debug("updateEntity inputMap {}", inputMap);
logger.debug("updateEntity inputEntity {}", inputEntity);
response = getClient(index.toLowerCase()).update(new UpdateRequest(index.toLowerCase(), osid).doc(inputMap), RequestOptions.DEFAULT);
} catch (IOException e) {
logger.error("Exception in updating a record to ElasticSearch", e);
}
return response.status();
}
java/elastic-search/src/main/java/dev/sunbirdrc/elastic/ElasticServiceImpl.java:252
- deleteEntity() uses NullPointerException for control flow (when readEntity returns null) and also maps IOException to NOT_FOUND. This can hide real failures (e.g., OpenSearch unavailable) as 404s. Prefer an explicit null/exists check for the read result, and handle IOException separately (e.g., return an error status).
public RestStatus deleteEntity(String index, String osid) {
UpdateResponse response = null;
try {
String indexL = index.toLowerCase();
Map<String, Object> readMap = readEntity(indexL, osid);
// Map<String, Object> entityMap = (Map<String, Object>) readMap.get(index);
readMap.put(Constants.STATUS_KEYWORD, Constants.STATUS_INACTIVE);
response = getClient(indexL).update(new UpdateRequest(indexL, osid).doc(readMap), RequestOptions.DEFAULT);
} catch (NullPointerException | IOException e) {
logger.error("exception in deleteEntity {}", e);
return RestStatus.NOT_FOUND;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pallakartheekreddy
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Migrates registry and elastic-search modules from Elasticsearch 7.10.1 to OpenSearch 2.19.5. Updates Java dependencies, Docker base images, and API imports to ensure compatibility with OpenSearch 2.x architecture.
Type of Change
Microservice(s) Affected
registry(core)elastic-search(core)Changes
Dependencies (
4cb5f7c3):elasticsearch-rest-high-level-client 7.10.1withopensearch-rest-high-level-client 2.19.52.18.2(StreamWriteConstraints required by OpenSearch 2.x, added in Jackson 2.16)zstd-jni 1.5.5-5for compression support (CompressorRegistry requirement)httpclient 4.5.14,httpcore 4.4.16,httpasyncclient 4.1.5,httpcore-nio 4.4.16Source migration:
org.elasticsearch.*imports toorg.opensearch.*inElasticServiceImpl.javaandIElasticService.javaRestStatusimport toorg.opensearch.core.rest.RestStatusCreateIndexRequestto useorg.opensearch.client.indicespackage_doctype arguments from all operations — type system removed in OpenSearch 2.xES_DOC_TYPEconstant fromConstants.javaelasticService.setType()calls from entity configurationDocker updates (
1fc59ac3):frolvlad/alpine-java:jdk8-slim→eclipse-temurin:11-jre-alpineopenjdk:8-jdk-alpine(run integration tests with original base)Docker Compose:
opensearchproject/opensearch:2.19.5ES_JAVA_OPTS→OPENSEARCH_JAVA_OPTSplugins.security.disabled=truefor local devTest Artifacts (
java/opensearch-api-test.md):How Has This Been Tested?
Checklist
Notes