Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HSEARCH-5218 Add compatibility with OpenSearch 2.16.0 #4266

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ stage('Configure') {
new LocalOpenSearchBuildEnvironment(version: '2.12.0', condition: TestCondition.ON_DEMAND),
new LocalOpenSearchBuildEnvironment(version: '2.13.0', condition: TestCondition.ON_DEMAND),
new LocalOpenSearchBuildEnvironment(version: '2.14.0', condition: TestCondition.ON_DEMAND),
new LocalOpenSearchBuildEnvironment(version: '2.15.0', condition: TestCondition.BEFORE_MERGE),
new LocalOpenSearchBuildEnvironment(version: '2.15.0', condition: TestCondition.ON_DEMAND),
new LocalOpenSearchBuildEnvironment(version: '2.16.0', condition: TestCondition.BEFORE_MERGE),
// See https://opensearch.org/lines/2x.html for a list of all 2.x versions
// IMPORTANT: Make sure to update the documentation for any newly supported OpenSearch versions
// See version.org.opensearch.compatible.expected.text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private ElasticsearchProtocolDialect createProtocolDialectOpenSearchV1(Elasticse
}

private ElasticsearchProtocolDialect createProtocolDialectOpenSearchV2(ElasticsearchVersion version, int minor) {
if ( minor > 15 ) {
if ( minor > 16 ) {
log.unknownElasticsearchVersion( version );
}
return new Elasticsearch70ProtocolDialect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,22 @@ public static List<? extends Arguments> params() {
ElasticsearchDistributionName.OPENSEARCH, "2.15.0", "2.15.0",
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
),
successWithWarning(
success(
ElasticsearchDistributionName.OPENSEARCH, "2.16", "2.16.0",
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
),
successWithWarning(
success(
ElasticsearchDistributionName.OPENSEARCH, "2.16.0", "2.16.0",
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
),
successWithWarning(
ElasticsearchDistributionName.OPENSEARCH, "2.17", "2.17.0",
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
),
successWithWarning(
ElasticsearchDistributionName.OPENSEARCH, "2.17.0", "2.17.0",
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
),
successWithWarning(
ElasticsearchDistributionName.OPENSEARCH, "3", "3.0.0",
OpenSearch214ModelDialect.class, Elasticsearch70ProtocolDialect.class
Expand Down Expand Up @@ -511,20 +519,6 @@ private void testUnsupported() {
.hasMessageContaining( "'" + distributionName.toString() + ":" + configuredVersionString + "'" );
}

private void testAmbiguous() {
assertThatThrownBy(
() -> {
dialectFactory.createModelDialect( ElasticsearchVersion.of( distributionName, configuredVersionString ) );
},
"Test ambiguous version " + configuredVersionString
)
.isInstanceOf( SearchException.class )
.hasMessageContaining( "HSEARCH400561" )
.hasMessageContaining(
"Ambiguous Elasticsearch version: '" + distributionName + ":" + configuredVersionString + "'." )
.hasMessageContaining( "Please use a more precise version to remove the ambiguity" );
}

private void testSuccessWithWarning() {
ElasticsearchVersion parsedConfiguredVersion = ElasticsearchVersion.of( distributionName, configuredVersionString );
ElasticsearchVersion parsedActualVersion = ElasticsearchVersion.of( distributionName, actualVersionString );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# IMPORTANT! When updating the version of OpenSearch in this Dockerfile,
# make sure to update `version.org.opensearch.latest` property in a POM file,
# and to update the version in opensearch.Dockerfile as well.
FROM docker.io/opensearchproject/opensearch:2.15.0
FROM docker.io/opensearchproject/opensearch:2.16.0
2 changes: 1 addition & 1 deletion build/container/search-backend/opensearch.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# IMPORTANT! When updating the version of OpenSearch in this Dockerfile,
# make sure to update `version.org.opensearch.latest` property in a POM file,
# and to update the version in amazon-opensearch-serverless.Dockerfile as well.
FROM docker.io/opensearchproject/opensearch:2.15.0
FROM docker.io/opensearchproject/opensearch:2.16.0
4 changes: 2 additions & 2 deletions build/parents/build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@
-->
<!-- The versions of OpenSearch advertised as compatible with Hibernate Search -->
<!-- Make sure to only mention tested versions here -->
<version.org.opensearch.compatible.regularly-tested.text>1.3 or 2.15</version.org.opensearch.compatible.regularly-tested.text>
<version.org.opensearch.compatible.regularly-tested.text>1.3 or 2.16</version.org.opensearch.compatible.regularly-tested.text>
<!-- These are the versions same as above, but pointing only to the major part (used in compatibility section of ES backend documentation
as versions that Hibernate Search is compatible with. -->
<!-- NOTE: Adding new major versions would require to update the compatibility table in `backend-elasticsearch-compatibility` section of `backend-elasticsearch.asciidoc`. -->
<version.org.opensearch.compatible.expected.text>1.3 or 2.x</version.org.opensearch.compatible.expected.text>
<!-- The latest version of OpenSearch tested against by default -->
<version.org.opensearch.latest>2.15.0</version.org.opensearch.latest>
<version.org.opensearch.latest>2.16.0</version.org.opensearch.latest>
<!-- The main compatible version of OpenSearch, advertised by default. Used in documentation links. -->
<version.org.opensearch.compatible.main>${version.org.opensearch.latest}</version.org.opensearch.compatible.main>
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,16 @@ public Optional<Comparator<? super Object>> rawValueEqualsComparator(FieldTypeDe
public boolean normalizesStringArgumentToPrefixPredicateForAnalyzedStringField() {
return false;
}

@Override
public boolean rangeAggregationsDoNotIgnoreQuery() {
// See https://github.com/opensearch-project/OpenSearch/issues/15169
// There is a problem with OpenSearch 2.16.0 where query is ignored for a range aggregation,
// leading to routes, being ignored and incorrect counts produced in the results:
return isActualVersion(
es -> true,
os -> os.isLessThan( "2.16.0" ),
aoss -> false
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -26,6 +27,7 @@
import org.hibernate.search.integrationtest.backend.tck.testsupport.operations.expectations.UnsupportedSingleFieldAggregationExpectations;
import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ExpectationsAlternative;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TypeAssertionHelper;
import org.hibernate.search.util.common.data.Range;
import org.hibernate.search.util.impl.integrationtest.common.NormalizationUtils;
Expand Down Expand Up @@ -129,6 +131,10 @@ public AggregationScenario<?> onMultiValuedIndex() {

private <T> AggregationScenario<Map<Range<T>, Long>> doCreate(Map<Range<F>, Long> expectedResult,
TypeAssertionHelper<F, T> helper) {
assumeTrue(
TckConfiguration.get().getBackendFeatures().rangeAggregationsDoNotIgnoreQuery()
);

return new AggregationScenario<Map<Range<T>, Long>>() {
@Override
public AggregationFinalStep<Map<Range<T>, Long>> setup(SearchAggregationFactory factory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,8 @@ public Optional<Comparator<? super Object>> rawValueEqualsComparator(FieldTypeDe
public boolean normalizesStringArgumentToPrefixPredicateForAnalyzedStringField() {
return true;
}

public boolean rangeAggregationsDoNotIgnoreQuery() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import static org.hibernate.search.integrationtest.showcase.library.service.TestDataService.SUBURBAN_2_ID;
import static org.hibernate.search.integrationtest.showcase.library.service.TestDataService.THESAURUS_OF_LANGUAGES_ID;
import static org.hibernate.search.integrationtest.showcase.library.service.TestDataService.UNIVERSITY_ID;
import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect.isActualVersion;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -462,6 +464,15 @@ void searchAndProjectToMethodLocalClass() {

@Test
void searchFaceted() {
assumeTrue(
TestActiveProfilesResolver.isLucene()
|| isActualVersion(
es -> true,
// See https://github.com/opensearch-project/OpenSearch/issues/15169
os -> os.isLessThan( "2.16.0" ),
aoss -> false
)
);
LibraryFacetedSearchResult result = libraryService.searchFaceted(
null, null, null,
0, 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public String[] resolve(Class<?> testClass) {
public static String configuredBackend() {
return System.getProperty( "test.backend", DEFAULT_BACKEND );
}

public static boolean isLucene() {
return DEFAULT_BACKEND.equals( configuredBackend() );
}
}