Skip to content

Commit

Permalink
Dependency updates: Spring Boot 3.4.0, Spring Framework 6.2, Spring D…
Browse files Browse the repository at this point in the history
…ata Elasticsearch 5.4.0

Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Nov 15, 2024
1 parent d5762c3 commit 67171c6
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The Spring Data OpenSearch follows the release model of the Spring Data Elastics

| Spring Data Release Train | Spring Data OpenSearch | Spring Data Elasticsearch | OpenSearch Server | OpenSearch Client | Spring Framework | Spring Boot |
|---------------------------|------------------------|---------------------------|-------------------|-------------------|------------------|---------------|
| 2024.1 | 1.6.x | 5.4.x | 1.x / 2.x | 2.10.x and above | 6.2.x | 3.4.x |
| 2024.0 | 1.5.x | 5.3.x | 1.x / 2.x | 2.10.x and above | 6.1.x | 3.2.x / 3.3.x |
| 2023.1 (Vaughan) | 1.4.x | 5.2.x | 1.x / 2.x | 2.10.x and above | 6.1.x | 3.2.x |
| 2023.1 (Vaughan) | 1.3.x | 5.2.x | 1.x / 2.x | 2.7.x and above | 6.1.x | 3.2.x |
Expand Down
14 changes: 10 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ dependencyResolutionManagement {
}

create("springLibs") {
version("spring", "6.1.14")
version("spring-boot", "3.3.5")
library("data-commons", "org.springframework.data:spring-data-commons:3.3.5")
library("data-elasticsearch", "org.springframework.data:spring-data-elasticsearch:5.3.5")
version("spring", "6.2.0")
version("spring-boot", "3.4.0-RC1")
library("data-commons", "org.springframework.data:spring-data-commons:3.4.0")
library("data-elasticsearch", "org.springframework.data:spring-data-elasticsearch:5.4.0")
library("web", "org.springframework", "spring-web").versionRef("spring")
library("context", "org.springframework", "spring-context").versionRef("spring")
library("tx", "org.springframework", "spring-tx").versionRef("spring")
Expand Down Expand Up @@ -72,12 +72,18 @@ pluginManagement {
maven {
url = uri("https://repo.spring.io/release/")
}
maven {
url = uri("https://repo.spring.io/milestone/")
}
}
}

dependencyResolutionManagement {
repositories {
mavenCentral()
maven {
url = uri("https://repo.spring.io/milestone/")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public static SearchDocument from(SearchHit source) {
if (sourceInnerHits != null) {
sourceInnerHits.forEach((name, searchHits) -> innerHits.put(
name,
SearchDocumentResponseBuilder.from(
searchHits, null, null, null, null, searchDocument -> CompletableFuture.completedFuture(null))));
SearchDocumentResponseBuilder.from(searchHits, null, null, 0, null, null,
searchDocument -> CompletableFuture.completedFuture(null))));
}

NestedMetaData nestedMetaData = from(source.getNestedIdentity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@
import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.SqlQuery;
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.core.query.UpdateResponse;
import org.springframework.data.elasticsearch.core.reindex.ReindexRequest;
import org.springframework.data.elasticsearch.core.reindex.ReindexResponse;
import org.springframework.data.elasticsearch.core.sql.SqlResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -631,6 +633,11 @@ protected MultiSearchResponse.Item[] getMultiSearchResult(MultiSearchRequest req
return items;
}

@Override
public SqlResponse search(SqlQuery query) {
throw new UnsupportedOperationException("The operation search(SqlQuery query) is not supported");
}

// endregion

// region ClientCallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package org.opensearch.data.client.orhlc;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -59,8 +60,10 @@ public static <T> SearchDocumentResponse from(
Aggregations aggregations = searchResponse.getAggregations();
org.opensearch.search.suggest.Suggest suggest = searchResponse.getSuggest();
SearchShardStatistics shardStatistics = shardsFrom(searchResponse);
var executionDurationInMillis = searchResponse.getTook().millis();

return from(searchHits, shardStatistics, scrollId, aggregations, suggest, entityCreator);
return from(searchHits, shardStatistics, scrollId, executionDurationInMillis,
aggregations, suggest, entityCreator);
}

/**
Expand All @@ -79,6 +82,7 @@ public static <T> SearchDocumentResponse from(
SearchHits searchHits,
@Nullable SearchShardStatistics shardStatistics,
@Nullable String scrollId,
long executionDurationInMillis,
@Nullable Aggregations aggregations,
@Nullable org.opensearch.search.suggest.Suggest suggestOS,
SearchDocumentResponse.EntityCreator<T> entityCreator) {
Expand All @@ -97,6 +101,7 @@ public static <T> SearchDocumentResponse from(
}

float maxScore = searchHits.getMaxScore();
final Duration executionDuration = Duration.ofMillis(executionDurationInMillis);

List<SearchDocument> searchDocuments = new ArrayList<>();
for (SearchHit searchHit : searchHits) {
Expand All @@ -113,6 +118,7 @@ public static <T> SearchDocumentResponse from(
totalHits,
totalHitsRelation,
maxScore,
executionDuration,
scrollId,
null,
searchDocuments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static SearchDocument from(Hit<?> hit, JsonpMapper jsonpMapper) {
Map<String, SearchDocumentResponse> innerHits = new LinkedHashMap<>();
hit.innerHits().forEach((name, innerHitsResult) -> {
// noinspection ReturnOfNull
innerHits.put(name, SearchDocumentResponseBuilder.from(innerHitsResult.hits(), null, null, null, null, null,
innerHits.put(name, SearchDocumentResponseBuilder.from(innerHitsResult.hits(), null, null, null, 0, null, null,
searchDocument -> null, jsonpMapper));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.SearchTemplateQuery;
import org.springframework.data.elasticsearch.core.query.SqlQuery;
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.core.query.UpdateResponse;
import org.springframework.data.elasticsearch.core.reindex.ReindexRequest;
import org.springframework.data.elasticsearch.core.reindex.ReindexResponse;
import org.springframework.data.elasticsearch.core.script.Script;
import org.springframework.data.elasticsearch.core.sql.SqlResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -642,6 +644,11 @@ public List<PitInfo> listPointInTime() {
.toList();
}

@Override
public SqlResponse search(SqlQuery query) {
throw new UnsupportedOperationException("The operation search(SqlQuery query) is not supported");
}

// endregion

// region script methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.opensearch.data.client.osc;

import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -79,8 +80,9 @@ public static <T> SearchDocumentResponse from(SearchResult<EntityAsMap> response
Map<String, List<org.opensearch.client.opensearch.core.search.Suggest<EntityAsMap>>> suggest = responseBody.suggest();
var pointInTimeId = responseBody.pitId();
var shards = responseBody.shards();
var executionDurationInMillis = responseBody.took();

return from(hitsMetadata, shards, scrollId, pointInTimeId, aggregations, suggest, entityCreator, jsonpMapper);
return from(hitsMetadata, shards, scrollId, pointInTimeId, executionDurationInMillis, aggregations, suggest, entityCreator, jsonpMapper);
}

/**
Expand All @@ -105,8 +107,9 @@ public static <T> SearchDocumentResponse from(SearchTemplateResponse<EntityAsMap
var suggest = response.suggest();
var pointInTimeId = response.pitId();
var shards = response.shards();
var executionDurationInMillis = response.took();

return from(hitsMetadata, shards, scrollId, pointInTimeId, aggregations, suggest, entityCreator, jsonpMapper);
return from(hitsMetadata, shards, scrollId, pointInTimeId, executionDurationInMillis, aggregations, suggest, entityCreator, jsonpMapper);
}

/**
Expand All @@ -123,7 +126,7 @@ public static <T> SearchDocumentResponse from(SearchTemplateResponse<EntityAsMap
* @return the {@link SearchDocumentResponse}
*/
public static <T> SearchDocumentResponse from(HitsMetadata<?> hitsMetadata, @Nullable ShardStatistics shards,
@Nullable String scrollId, @Nullable String pointInTimeId, @Nullable Map<String, Aggregate> aggregations,
@Nullable String scrollId, @Nullable String pointInTimeId, long executionDurationInMillis, @Nullable Map<String, Aggregate> aggregations,
Map<String, List<org.opensearch.client.opensearch.core.search.Suggest<EntityAsMap>>> suggestES, SearchDocumentResponse.EntityCreator<T> entityCreator,
JsonpMapper jsonpMapper) {

Expand All @@ -146,6 +149,7 @@ public static <T> SearchDocumentResponse from(HitsMetadata<?> hitsMetadata, @Nul
}

float maxScore = hitsMetadata.maxScore() != null ? hitsMetadata.maxScore().floatValue() : Float.NaN;
final Duration executionDuration = Duration.ofMillis(executionDurationInMillis);

List<SearchDocument> searchDocuments = new ArrayList<>();
for (Hit<?> hit : hitsMetadata.hits()) {
Expand All @@ -159,8 +163,8 @@ public static <T> SearchDocumentResponse from(HitsMetadata<?> hitsMetadata, @Nul

SearchShardStatistics shardStatistics = shards != null ? shardsFrom(shards) : null;

return new SearchDocumentResponse(totalHits, totalHitsRelation, maxScore, scrollId, pointInTimeId, searchDocuments,
aggregationsContainer, suggest, shardStatistics);
return new SearchDocumentResponse(totalHits, totalHitsRelation, maxScore, executionDuration,
scrollId, pointInTimeId, searchDocuments, aggregationsContainer, suggest, shardStatistics);
}

private static SearchShardStatistics shardsFrom(ShardStatistics shards) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.opensearch.action.search.SearchScrollRequest;
import org.opensearch.client.RequestOptions;
import org.opensearch.client.RestHighLevelClient;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.common.bytes.BytesArray;
import org.opensearch.data.client.orhlc.OpenSearchRestTemplate;

Expand Down Expand Up @@ -101,6 +102,7 @@ public void setUp() throws Exception {
doReturn(searchResponse).when(client).search(any(SearchRequest.class), any(RequestOptions.class));
doReturn(nSearchHits(2)).when(searchResponse).getHits();
doReturn("scroll-id").when(searchResponse).getScrollId();
doReturn(TimeValue.timeValueMillis(100)).when(searchResponse).getTook();
doReturn(new BytesArray(new byte[8])).when(searchHit).getSourceRef();
doReturn(new HashMap<String, Object>() {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void shouldGetPhraseSuggestion() throws JSONException {
.build();

// act
final var actual = SearchDocumentResponseBuilder.from(hitsMetadata, null, null, null, null, sortProperties, null,
final var actual = SearchDocumentResponseBuilder.from(hitsMetadata, null, null, null, 0, null, sortProperties, null,
jsonpMapper);

// assert
Expand Down Expand Up @@ -151,7 +151,7 @@ void shouldGetShardStatisticsInfo() {

// act
SearchDocumentResponse response = SearchDocumentResponseBuilder.from(hitsMetadata, shards, null, null,
null, null, null, jsonpMapper);
0, null, null, null, jsonpMapper);

// assert
SearchShardStatistics shardStatistics = response.getSearchShardStatistics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.opensearch.data.client.EnabledIfOpenSearchVersion;
import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -92,6 +93,13 @@ void setUp() {
void cleanup() {
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete();
}

@Test
@EnabledIfOpenSearchVersion(onOrAfter = "2.15.0", reason = "https://github.com/opensearch-project/OpenSearch/issues/5639")
public void shouldSupportAllTypes() {
IndexOperations indexOperations = operations.indexOps(EntityWithAllTypes.class);
indexOperations.createWithMapping();
}

@Test
public void shouldNotFailOnCircularReference() {
Expand Down Expand Up @@ -853,7 +861,7 @@ private static class EntityWithAllTypes {
@Nullable
@Field(type = FieldType.Percolator) String percolatorField;
@Nullable
@Field(type = FieldType.Flattened) String flattenedField;
@Field(type = FieldType.Flattened, mappedTypeName = "flat_object") String flattenedField;
@Nullable
@Field(type = FieldType.Search_As_You_Type) String searchAsYouTypeField;
@Nullable
Expand All @@ -862,8 +870,6 @@ private static class EntityWithAllTypes {
@Field(type = FieldType.Rank_Features) String rankFeaturesField;
@Nullable
@Field(type = FieldType.Wildcard) String wildcardField;
@Nullable
@Field(type = FieldType.Dense_Vector, dims = 1) String denseVectorField;
}
// endregion
}
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.5.4
version=1.6.0

0 comments on commit 67171c6

Please sign in to comment.