Repository navigation
Support OpenSearch 2 and 3 with the Elasticsearch index backend - #4993
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
OpenSearch detection currently accepts malformed and unsupported future major versions without validation.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Extends the Elasticsearch backend to support OpenSearch 2 and 3.
Changes:
- Detects OpenSearch and applies Elasticsearch 7-compatible behavior without mapping types.
- Adds an explicit Elasticsearch API major-version option.
- Adds OpenSearch tests, CI lanes, container setup, and documentation.
| File | Description |
|---|---|
TESTING.md |
Documents OpenSearch test profiles. |
RestClientSetupTest.java |
Tests major-version configuration plumbing. |
RestClientMajorVersionTest.java |
Tests detection and mapping-type behavior. |
JanusGraphElasticsearchContainer.java |
Configures OpenSearch test containers. |
ElasticsearchConfigTest.java |
Tests effective mapping behavior. |
ElasticMajorVersionTest.java |
Covers version classification. |
RestElasticSearchClient.java |
Detects OpenSearch and handles mapping types. |
RestClientSetup.java |
Passes configured API versions to clients. |
ElasticSearchIndex.java |
Defines the new option and exposes effective mappings. |
ElasticSearchClient.java |
Adds mapping-type capability reporting. |
ElasticMajorVersion.java |
Maps OpenSearch to the ES 7 API. |
janusgraph-es/pom.xml |
Adds OpenSearch test profiles. |
docs/index-backend/index.md |
Mentions OpenSearch support. |
docs/index-backend/elasticsearch.md |
Documents OpenSearch configuration. |
docs/configs/janusgraph-cfg.md |
Documents the new option. |
docs/changelog.md |
Records compatibility and upgrade notes. |
.github/workflows/ci-index-es.yml |
Adds OpenSearch CI jobs. |
.github/workflows/ci-index-es-dummy.yml |
Mirrors the new CI matrix entries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
9c0b320 to
cbd18ed
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 3
Open (5)
This section is internally inconsistent: it first claims support for OpenSearch “2 and 3”, then… · New This section is internally inconsistent: it first claims support for OpenSearch “2 and 3”, then… · New Detecting OpenSearch via a substring match on the image name is brittle (e.g., custom registries or… · New The warning message is misleading for OpenSearch 3 (and any future 2+ version) because it… · New Using an untypedany()for the newElasticMajorVersionparameter weakens Mockito’s type safety… · New
Resolved since last review (1)
cbd18ed to
6633ee7
Compare
Fixes JanusGraph#4887 OpenSearch was forked from Elasticsearch 7.10 and provides its API, but it reports its own version (2.x, 3.x) with the distribution "opensearch". JanusGraph rejected these versions as unsupported Elasticsearch versions. OpenSearch 2 only worked with compatibility.override_main_response_version, and OpenSearch 3 removed that setting. * A cluster which reports the distribution opensearch with a major version of 2 or 3 is now treated as Elasticsearch 7. Other OpenSearch versions, including OpenSearch 1, which reached its end of life, are rejected like unsupported Elasticsearch versions. * OpenSearch 2 removed mapping types, so when JanusGraph detects OpenSearch it ignores use-mapping-for-es7 with a warning, and requests are always typeless. ElasticSearchClient.usesMappingTypes() exposes the effective choice, which ElasticsearchConfigTest now checks against every cluster. * The new option index.[X].elasticsearch.major-version sets the major version of the Elasticsearch API which the cluster provides (6 to 9). When it is set, JanusGraph doesn't ask the cluster for its version, which also lets ES compatible services work whose root endpoint doesn't report a usable version. The detection fallback and the unsupported version error point to it. * The test container starts OpenSearch images with the security plugin disabled and without Elasticsearch's X-Pack and GeoIP settings, which OpenSearch refuses to start with. The property elasticsearch.docker.distribution, which the opensearch profiles set, says which distribution an image is; without it, the repository name of the image decides. * New profiles opensearch2 (2.19.6) and opensearch3 (3.9.0) run the Elasticsearch tests against OpenSearch, and CI runs them on Java 11 and 25. * The docs describe OpenSearch support: * the security plugin * setup-max-open-scroll-contexts=false where the JanusGraph user may not update cluster settings, including Amazon OpenSearch Service * that Amazon OpenSearch Serverless (no scroll API, no stored scripts) isn't supported Co-Authored-By: Oleksandr Porunov <alexandr.porunov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
6633ee7 to
292bbed
Compare
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation, tests, CI coverage, and documentation consistently support the stated OpenSearch compatibility behavior.
Review effort: Balanced
Findings: None
Resolved since last review (5)
Detecting OpenSearch via a substring match on the image name is brittle (e.g., custom registries or… This section is internally inconsistent: it first claims support for OpenSearch “2 and 3”, then… This section is internally inconsistent: it first claims support for OpenSearch “2 and 3”, then… Using an untypedany()for the newElasticMajorVersionparameter weakens Mockito’s type safety… The warning message is misleading for OpenSearch 3 (and any future 2+ version) because it…


Fixes #4887
JanusGraph's Elasticsearch index backend now supports OpenSearch 2 and 3. There's also a new option,
index.[X].elasticsearch.major-version, which sets the version explicitly so that auto-detection isn't needed.Problem
OpenSearch was forked from Elasticsearch 7.10 and provides the Elasticsearch 7 API. However, its root endpoint reports its own version (
"distribution": "opensearch","number": "2.19.6"/"3.9.0"). JanusGraph parses that number as an Elasticsearch major version, and fails withUnsupported Elasticsearch server major version.compatibility.override_main_response_version: true, which makes it report7.10.2.unknown setting [compatibility.override_main_response_version]). So JanusGraph couldn't use OpenSearch 3 at all.Changes
opensearchwith a major version of 2 or 3 is treated as Elasticsearch 7 (ElasticMajorVersion.fromServerVersion), and an info message is logged.major-version. That covers a future OpenSearch 4, a malformed version, and OpenSearch 1, which reached its end of life in May 2025 and which nothing tests. Users of OpenSearch 1 can setmajor-version=7, and it then behaves like Elasticsearch 7 including mapping types.ElasticsearchIndexTestpasses on OpenSearch 3 with this alone.include_type_nameis an unrecognized parameter.use-mapping-for-es7is ignored with a warning, and requests are always typeless, because OpenSearch 2 removed mapping types.ElasticSearchClient.usesMappingTypes()(a default method, overridden by the REST client) exposes the flag JanusGraph actually uses, soElasticsearchConfigTestchecks the effective behavior. Its mapping-type variant therefore now also runs against OpenSearch and proves the override.retry_on_conflict, the scroll-context setup, and geo_shape prefix trees, which OpenSearch 3 still supports (the prefix-tree tests pass). So mapping OpenSearch to ES 8 would have given up a feature it has.index.[X].elasticsearch.major-version(6–9, MASKABLE, no default): the major version of the Elasticsearch API which the cluster provides, as the maintainers asked for. When set, JanusGraph doesn't requestGET /for the version.7. With an explicit version (oroverride_main_response_version) JanusGraph can't tell that it's OpenSearch, so the docs and the option descriptions say to keepuse-mapping-for-es7disabled in that case.RestClientSetuppasses it to the REST client through a new constructor overload. The old constructor still asks the cluster, so existing callers are unchanged.elasticsearch.docker.distribution(elasticsearch/opensearch), which theopensearch2/opensearch3profiles set. Without it, the parsed image's repository name decides (opensearchproject/opensearchfrom any registry), so the documented-Delasticsearch.docker.image=opensearchproject/opensearchform keeps working; a differently named OpenSearch image needs the property.ElasticsearchContainer; its single-node settings and "started" log wait work unchanged.getEsMajorVersion()is 7.opensearch2(2.19.6) andopensearch3(3.9.0), each run on Java 11 and Java 25, like the ES lanes.elasticsearch.md: detection, mapping types, the override setting,major-version, and security-plugin configuration;setup-max-open-scroll-contexts=falsefor users who may not update cluster settings, and for Amazon OpenSearch Service. AWS doesn't allow changingsearch.max_open_scroll_context, and otherwise graph open fails;TESTING.md;janusgraph-cfg.md.Tests
ElasticMajorVersionTest: ES 6–9, OpenSearch 2 and 3, the7.10.2override, OpenSearch detection, and unsupported Elasticsearch and OpenSearch versions (1.x, 0.x, 4.x, 10.x, malformed, missing).RestClientMajorVersionTest: a configured version sends no request, and a real OpenSearch 3.9.0 root response is detected as 7. Withuse-mapping-for-es7=true, an ES 7.17.8 response getsinclude_type_name, while OpenSearch doesn't. I checked that the OpenSearch case fails without the fix.RestClientSetupTest: the option reaches the client, and the default is null.ElasticsearchConfigTest: both variants run everywhere, with expectations based on the effective mapping-type use.@Disabledmanual test.Floatmin/max assertions from Upgrade to Solr 9 and Lucene 9 #4992.-Popensearch3(the explicit distribution property);-Delasticsearch.docker.image=opensearchproject/opensearchwithout a profile (the repository-name fallback).mvn -fae validate(enforcer, RAT, Checkstyle) over the reactor.Not included
RestClientSetup.connectdoesn't close the low-levelRestClientit built.Note
Rebased onto master after #4992 (Solr 9) was merged.
Copilot's review comments are addressed: OpenSearch 1 is no longer accepted, so the code and the docs agree on "2 and 3"; the test container takes an explicit distribution property and otherwise compares the image's repository name instead of a substring; the mapping-types warning no longer says "OpenSearch 2" for OpenSearch 3; and the
RestClientSetupTeststubs usenullable(ElasticMajorVersion.class).🤖 Generated with Claude Code