Skip to content

Commit 6011942

Browse files
committed
HSEARCH-5363 Add compatibility with OpenSearch 3.0.0
1 parent 88751cc commit 6011942

File tree

10 files changed

+50
-16
lines changed

10 files changed

+50
-16
lines changed

Jenkinsfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ stage('Configure') {
286286
new LocalOpenSearchBuildEnvironment(version: '2.16.0', condition: TestCondition.ON_DEMAND),
287287
new LocalOpenSearchBuildEnvironment(version: '2.17.1', condition: TestCondition.ON_DEMAND),
288288
new LocalOpenSearchBuildEnvironment(version: '2.18.0', condition: TestCondition.ON_DEMAND),
289-
new LocalOpenSearchBuildEnvironment(version: '2.19.2', condition: TestCondition.BEFORE_MERGE),
289+
new LocalOpenSearchBuildEnvironment(version: '2.19.2', condition: TestCondition.AFTER_MERGE),
290+
new LocalOpenSearchBuildEnvironment(version: '3.0.0', condition: TestCondition.BEFORE_MERGE),
290291
// See https://opensearch.org/lines/2x.html for a list of all 2.x versions
291292
// IMPORTANT: Make sure to update the documentation for any newly supported OpenSearch versions
292293
// See version.org.opensearch.compatible.expected.text

backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/dialect/impl/ElasticsearchDialectFactory.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ else if ( major == 1 ) {
136136
return new OpenSearch29ModelDialect();
137137
}
138138
}
139+
if ( major == 3 ) {
140+
// While at the moment this if is redundant, it is more of a placeholder
141+
return new OpenSearch214ModelDialect();
142+
}
139143
return new OpenSearch214ModelDialect();
140144
}
141145
}
@@ -237,6 +241,9 @@ else if ( major == 1 ) {
237241
else if ( major == 2 ) {
238242
return createProtocolDialectOpenSearchV2( version, minor );
239243
}
244+
else if ( major == 3 ) {
245+
return createProtocolDialectOpenSearchV3( version, minor );
246+
}
240247
else {
241248
VersionLog.INSTANCE.unknownElasticsearchVersion( version );
242249
return new Elasticsearch70ProtocolDialect();
@@ -257,6 +264,13 @@ private ElasticsearchProtocolDialect createProtocolDialectOpenSearchV2(Elasticse
257264
return new Elasticsearch70ProtocolDialect();
258265
}
259266

267+
private ElasticsearchProtocolDialect createProtocolDialectOpenSearchV3(ElasticsearchVersion version, int minor) {
268+
if ( minor > 0 ) {
269+
VersionLog.INSTANCE.unknownElasticsearchVersion( version );
270+
}
271+
return new Elasticsearch70ProtocolDialect();
272+
}
273+
260274
private ElasticsearchProtocolDialect createProtocolDialectAmazonOpenSearchServerless(ElasticsearchVersion version) {
261275
if ( !AMAZON_OPENSEARCH_SERVERLESS.equals( version ) ) {
262276
throw VersionLog.INSTANCE.unexpectedAwsOpenSearchServerlessVersion( version, AMAZON_OPENSEARCH_SERVERLESS );

backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/dialect/impl/ElasticsearchDialectFactoryTest.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,16 +496,32 @@ public static List<? extends Arguments> params() {
496496
ElasticsearchDistributionName.OPENSEARCH, "2.20.0", "2.20.0",
497497
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
498498
),
499+
success(
500+
ElasticsearchDistributionName.OPENSEARCH, "3.0", "3.0.0",
501+
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
502+
),
503+
success(
504+
ElasticsearchDistributionName.OPENSEARCH, "3.0.0", "3.0.0",
505+
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
506+
),
499507
successWithWarning(
500-
ElasticsearchDistributionName.OPENSEARCH, "3", "3.0.0",
508+
ElasticsearchDistributionName.OPENSEARCH, "3.1", "3.1.0",
501509
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
502510
),
503511
successWithWarning(
504-
ElasticsearchDistributionName.OPENSEARCH, "3.0", "3.0.0",
512+
ElasticsearchDistributionName.OPENSEARCH, "3.1.0", "3.1.0",
505513
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
506514
),
507515
successWithWarning(
508-
ElasticsearchDistributionName.OPENSEARCH, "3.0.0", "3.0.0",
516+
ElasticsearchDistributionName.OPENSEARCH, "4", "4.0.0",
517+
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
518+
),
519+
successWithWarning(
520+
ElasticsearchDistributionName.OPENSEARCH, "4.0", "4.0.0",
521+
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
522+
),
523+
successWithWarning(
524+
ElasticsearchDistributionName.OPENSEARCH, "4.0.0", "4.0.0",
509525
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
510526
)
511527
);

build/container/search-backend/amazon-opensearch-serverless.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# IMPORTANT! When updating the version of OpenSearch in this Dockerfile,
55
# make sure to update `version.org.opensearch.latest` property in a POM file,
66
# and to update the version in opensearch.Dockerfile as well.
7-
FROM docker.io/opensearchproject/opensearch:2.19.2
7+
FROM docker.io/opensearchproject/opensearch:3.0.0

build/container/search-backend/opensearch.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# IMPORTANT! When updating the version of OpenSearch in this Dockerfile,
55
# make sure to update `version.org.opensearch.latest` property in a POM file,
66
# and to update the version in amazon-opensearch-serverless.Dockerfile as well.
7-
FROM docker.io/opensearchproject/opensearch:2.19.2
7+
FROM docker.io/opensearchproject/opensearch:3.0.0

build/parents/build/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@
7070
-->
7171
<!-- The versions of OpenSearch advertised as compatible with Hibernate Search -->
7272
<!-- Make sure to only mention tested versions here -->
73-
<version.org.opensearch.compatible.regularly-tested.text>1.3 or 2.19</version.org.opensearch.compatible.regularly-tested.text>
73+
<version.org.opensearch.compatible.regularly-tested.text>1.3, 2.19 or 3.0</version.org.opensearch.compatible.regularly-tested.text>
7474
<!-- These are the versions same as above, but pointing only to the major part (used in compatibility section of ES backend documentation
7575
as versions that Hibernate Search is compatible with. -->
7676
<!-- NOTE: Adding new major versions would require to update the compatibility table in `backend-elasticsearch-compatibility` section of `backend-elasticsearch.asciidoc`. -->
77-
<version.org.opensearch.compatible.expected.text>1.3 or 2.x</version.org.opensearch.compatible.expected.text>
77+
<version.org.opensearch.compatible.expected.text>1.3, 2.x or 3.x</version.org.opensearch.compatible.expected.text>
7878
<!-- The latest version of OpenSearch tested against by default -->
79-
<version.org.opensearch.latest>2.19.0</version.org.opensearch.latest>
79+
<version.org.opensearch.latest>3.0.0</version.org.opensearch.latest>
8080
<!-- The main compatible version of OpenSearch, advertised by default. Used in documentation links. -->
8181
<version.org.opensearch.compatible.main>${version.org.opensearch.latest}</version.org.opensearch.compatible.main>
8282
<documentation.org.opensearch.url>https://opensearch.org/docs/${parsed-version.org.opensearch.compatible.main.majorVersion}.${parsed-version.org.opensearch.compatible.main.minorVersion}</documentation.org.opensearch.url>

documentation/src/test/java/org/hibernate/search/documentation/search/query/ElasticsearchQueryDslIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void json() {
8686
parameters.put( "search_type", "dfs_query_then_fetch" );
8787

8888
JsonObject body = context.body(); // <4>
89-
body.addProperty( "min_score", 0.5f );
89+
body.addProperty( "min_score", 0.2f );
9090
} )
9191
.fetchHits( 20 ); // <5>
9292
// end::elasticsearch-requestTransformer[]

integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/custom/ElasticsearchCustomIndexSettingsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void unknownSetting() {
8282
.hasMessageContainingAll(
8383
"Hibernate Search encountered failures during bootstrap",
8484
"Elasticsearch response indicates a failure",
85-
"illegal_argument_exception", "unknown setting", "index.unknown_setting"
85+
"unknown setting", "index.unknown_setting"
8686
);
8787
}
8888

integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/mapping/VectorFieldIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ private static int maxDimension() {
224224
// with OpenSearch 2.12 the max size for a lucene engine is also set to 16_000
225225
// and since serverless is using the latest OpenSearch build - we should treat it the same:
226226
if ( ElasticsearchDistributionName.AMAZON_OPENSEARCH_SERVERLESS.equals( distribution )
227-
|| actualVersion.majorOptional().orElse( Integer.MIN_VALUE ) == 2
228-
&& ( actualVersion.minor().isEmpty() || actualVersion.minor().getAsInt() > 11 ) ) {
227+
|| ( actualVersion.majorOptional().orElse( Integer.MIN_VALUE ) == 2
228+
&& ( actualVersion.minor().isEmpty() || actualVersion.minor().getAsInt() > 11 ) )
229+
|| actualVersion.majorOptional().orElse( Integer.MIN_VALUE ) > 2 ) {
229230
return 16000;
230231
}
231232
else {

util/internal/integrationtest/backend/elasticsearch/src/main/java/org/hibernate/search/util/impl/integrationtest/backend/elasticsearch/SearchBackendContainer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,12 @@ private static GenericContainer<?> opensearch(DockerImageName dockerImageName) {
161161
ElasticsearchVersion version =
162162
ElasticsearchVersion.of( ElasticsearchDistributionName.OPENSEARCH, dockerImageName.getVersionPart() );
163163

164-
if ( version.majorOptional().orElse( Integer.MIN_VALUE ) == 2
165-
&& version.minor().orElse( Integer.MAX_VALUE ) > 11 ) {
164+
if ( ( version.majorOptional().orElse( Integer.MIN_VALUE ) == 2
165+
&& version.minor().orElse( Integer.MAX_VALUE ) > 11 )
166+
|| version.majorOptional().orElse( Integer.MIN_VALUE ) > 2 ) {
166167
// Note: For OpenSearch 2.12 and later, a custom password for the admin user is required to be passed to set-up and utilize demo configuration.
167-
container.withEnv( "OPENSEARCH_INITIAL_ADMIN_PASSWORD", "NotActua11y$trongPa$$word" );
168+
container.withEnv( "OPENSEARCH_INITIAL_ADMIN_PASSWORD", "NotActua11y$trongPa$$word" )
169+
.withEnv( "DISABLE_INSTALL_DEMO_CONFIG", "true" );
168170
}
169171
return container;
170172
}

0 commit comments

Comments
 (0)