Skip to content

Commit 7ff6834

Browse files
committed
support opensearch 2.x
1 parent 6c030f7 commit 7ff6834

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

janusgraph-es/src/main/java/org/janusgraph/diskstorage/es/ElasticMajorVersion.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package org.janusgraph.diskstorage.es;
1616

17+
import java.util.Map;
1718
import java.util.regex.Matcher;
1819
import java.util.regex.Pattern;
1920

@@ -39,7 +40,14 @@ public int getValue() {
3940
return value;
4041
}
4142

42-
public static ElasticMajorVersion parse(final String value) {
43+
public static ElasticMajorVersion parse(Map<String, Object> version) {
44+
// opensearch is mostly compatible with ElasticSearch 7.10
45+
if (version != null && "opensearch".equals(version.get("distribution")))
46+
return ElasticMajorVersion.SEVEN;
47+
return parse(version != null ? (String) version.get("number") : null);
48+
}
49+
50+
static ElasticMajorVersion parse(final String value) {
4351
final Matcher m = value != null ? PATTERN.matcher(value) : null;
4452
switch (m != null && m.find() ? Integer.parseInt(m.group(1)) : -1) {
4553
case 6:

janusgraph-es/src/main/java/org/janusgraph/diskstorage/es/rest/RestElasticSearchClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ public ElasticMajorVersion getMajorVersion() {
166166
final Response response = delegate.performRequest(INFO_REQUEST);
167167
try (final InputStream inputStream = response.getEntity().getContent()) {
168168
final ClusterInfo info = mapper.readValue(inputStream, ClusterInfo.class);
169-
majorVersion = ElasticMajorVersion.parse(info.getVersion() != null ? (String) info.getVersion().get("number") : null);
169+
majorVersion = ElasticMajorVersion.parse(info.getVersion());
170170
}
171-
} catch (final IOException e) {
171+
} catch (final IOException|IllegalArgumentException e) {
172172
log.warn("Unable to determine Elasticsearch server version. Default to {}.", majorVersion, e);
173173
}
174174

@@ -751,7 +751,7 @@ private Response performRequest(Request request, byte[] requestData) throws IOEx
751751
}
752752

753753
@JsonIgnoreProperties(ignoreUnknown=true)
754-
private static final class ClusterInfo {
754+
public static final class ClusterInfo {
755755

756756
private Map<String,Object> version;
757757

0 commit comments

Comments
 (0)