Skip to content

Commit 6b99d03

Browse files
authored
Dependency updates: Spring Boot 3.4.0, Spring Framework 6.2, Spring Data Elasticsearch 5.4.0 (#343)
Signed-off-by: Andriy Redko <[email protected]>
1 parent 012c909 commit 6b99d03

12 files changed

+53
-20
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The Spring Data OpenSearch follows the release model of the Spring Data Elastics
2424

2525
| Spring Data Release Train | Spring Data OpenSearch | Spring Data Elasticsearch | OpenSearch Server | OpenSearch Client | Spring Framework | Spring Boot |
2626
|---------------------------|------------------------|---------------------------|-------------------|-------------------|------------------|---------------|
27+
| 2024.1 | 1.6.x | 5.4.x | 1.x / 2.x | 2.10.x and above | 6.2.x | 3.4.x |
2728
| 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 |
2829
| 2023.1 (Vaughan) | 1.4.x | 5.2.x | 1.x / 2.x | 2.10.x and above | 6.1.x | 3.2.x |
2930
| 2023.1 (Vaughan) | 1.3.x | 5.2.x | 1.x / 2.x | 2.7.x and above | 6.1.x | 3.2.x |

settings.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ rootProject.name = "spring-data-opensearch-parent"
88
dependencyResolutionManagement {
99
versionCatalogs {
1010
create("libs") {
11-
version("jupiter", "5.11.2")
11+
version("jupiter", "5.11.3")
1212
library("jupiter", "org.junit.jupiter", "junit-jupiter").versionRef("jupiter")
1313
library("jupiter-params", "org.junit.jupiter", "junit-jupiter-params").versionRef("jupiter")
1414
}
1515

1616
create("springLibs") {
17-
version("spring", "6.1.15")
18-
version("spring-boot", "3.3.6")
19-
library("data-commons", "org.springframework.data:spring-data-commons:3.3.6")
20-
library("data-elasticsearch", "org.springframework.data:spring-data-elasticsearch:5.3.6")
17+
version("spring", "6.2.0")
18+
version("spring-boot", "3.4.0")
19+
library("data-commons", "org.springframework.data:spring-data-commons:3.4.0")
20+
library("data-elasticsearch", "org.springframework.data:spring-data-elasticsearch:5.4.0")
2121
library("web", "org.springframework", "spring-web").versionRef("spring")
2222
library("context", "org.springframework", "spring-context").versionRef("spring")
2323
library("tx", "org.springframework", "spring-tx").versionRef("spring")

spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/DocumentAdapters.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ public static SearchDocument from(SearchHit source) {
184184
if (sourceInnerHits != null) {
185185
sourceInnerHits.forEach((name, searchHits) -> innerHits.put(
186186
name,
187-
SearchDocumentResponseBuilder.from(
188-
searchHits, null, null, null, null, searchDocument -> CompletableFuture.completedFuture(null))));
187+
SearchDocumentResponseBuilder.from(searchHits, null, null, 0, null, null,
188+
searchDocument -> CompletableFuture.completedFuture(null))));
189189
}
190190

191191
NestedMetaData nestedMetaData = from(source.getNestedIdentity());

spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/OpenSearchRestTemplate.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@
7171
import org.springframework.data.elasticsearch.core.query.IndexQuery;
7272
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
7373
import org.springframework.data.elasticsearch.core.query.Query;
74+
import org.springframework.data.elasticsearch.core.query.SqlQuery;
7475
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
7576
import org.springframework.data.elasticsearch.core.query.UpdateResponse;
7677
import org.springframework.data.elasticsearch.core.reindex.ReindexRequest;
7778
import org.springframework.data.elasticsearch.core.reindex.ReindexResponse;
79+
import org.springframework.data.elasticsearch.core.sql.SqlResponse;
7880
import org.springframework.lang.Nullable;
7981
import org.springframework.util.Assert;
8082

@@ -631,6 +633,11 @@ protected MultiSearchResponse.Item[] getMultiSearchResult(MultiSearchRequest req
631633
return items;
632634
}
633635

636+
@Override
637+
public SqlResponse search(SqlQuery query) {
638+
throw new UnsupportedOperationException("The operation search(SqlQuery query) is not supported");
639+
}
640+
634641
// endregion
635642

636643
// region ClientCallback

spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/SearchDocumentResponseBuilder.java

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

1010
package org.opensearch.data.client.orhlc;
1111

12+
import java.time.Duration;
1213
import java.util.ArrayList;
1314
import java.util.Arrays;
1415
import java.util.List;
@@ -59,8 +60,10 @@ public static <T> SearchDocumentResponse from(
5960
Aggregations aggregations = searchResponse.getAggregations();
6061
org.opensearch.search.suggest.Suggest suggest = searchResponse.getSuggest();
6162
SearchShardStatistics shardStatistics = shardsFrom(searchResponse);
63+
var executionDurationInMillis = searchResponse.getTook().millis();
6264

63-
return from(searchHits, shardStatistics, scrollId, aggregations, suggest, entityCreator);
65+
return from(searchHits, shardStatistics, scrollId, executionDurationInMillis,
66+
aggregations, suggest, entityCreator);
6467
}
6568

6669
/**
@@ -79,6 +82,7 @@ public static <T> SearchDocumentResponse from(
7982
SearchHits searchHits,
8083
@Nullable SearchShardStatistics shardStatistics,
8184
@Nullable String scrollId,
85+
long executionDurationInMillis,
8286
@Nullable Aggregations aggregations,
8387
@Nullable org.opensearch.search.suggest.Suggest suggestOS,
8488
SearchDocumentResponse.EntityCreator<T> entityCreator) {
@@ -97,6 +101,7 @@ public static <T> SearchDocumentResponse from(
97101
}
98102

99103
float maxScore = searchHits.getMaxScore();
104+
final Duration executionDuration = Duration.ofMillis(executionDurationInMillis);
100105

101106
List<SearchDocument> searchDocuments = new ArrayList<>();
102107
for (SearchHit searchHit : searchHits) {
@@ -113,6 +118,7 @@ public static <T> SearchDocumentResponse from(
113118
totalHits,
114119
totalHitsRelation,
115120
maxScore,
121+
executionDuration,
116122
scrollId,
117123
null,
118124
searchDocuments,

spring-data-opensearch/src/main/java/org/opensearch/data/client/osc/DocumentAdapters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static SearchDocument from(Hit<?> hit, JsonpMapper jsonpMapper) {
7373
Map<String, SearchDocumentResponse> innerHits = new LinkedHashMap<>();
7474
hit.innerHits().forEach((name, innerHitsResult) -> {
7575
// noinspection ReturnOfNull
76-
innerHits.put(name, SearchDocumentResponseBuilder.from(innerHitsResult.hits(), null, null, null, null, null,
76+
innerHits.put(name, SearchDocumentResponseBuilder.from(innerHitsResult.hits(), null, null, null, 0, null, null,
7777
searchDocument -> null, jsonpMapper));
7878
});
7979

spring-data-opensearch/src/main/java/org/opensearch/data/client/osc/OpenSearchTemplate.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@
5959
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
6060
import org.springframework.data.elasticsearch.core.query.Query;
6161
import org.springframework.data.elasticsearch.core.query.SearchTemplateQuery;
62+
import org.springframework.data.elasticsearch.core.query.SqlQuery;
6263
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
6364
import org.springframework.data.elasticsearch.core.query.UpdateResponse;
6465
import org.springframework.data.elasticsearch.core.reindex.ReindexRequest;
6566
import org.springframework.data.elasticsearch.core.reindex.ReindexResponse;
6667
import org.springframework.data.elasticsearch.core.script.Script;
68+
import org.springframework.data.elasticsearch.core.sql.SqlResponse;
6769
import org.springframework.lang.Nullable;
6870
import org.springframework.util.Assert;
6971

@@ -642,6 +644,11 @@ public List<PitInfo> listPointInTime() {
642644
.toList();
643645
}
644646

647+
@Override
648+
public SqlResponse search(SqlQuery query) {
649+
throw new UnsupportedOperationException("The operation search(SqlQuery query) is not supported");
650+
}
651+
645652
// endregion
646653

647654
// region script methods

spring-data-opensearch/src/main/java/org/opensearch/data/client/osc/SearchDocumentResponseBuilder.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.opensearch.data.client.osc;
1717

18+
import java.time.Duration;
1819
import java.util.ArrayList;
1920
import java.util.HashMap;
2021
import java.util.List;
@@ -79,8 +80,9 @@ public static <T> SearchDocumentResponse from(SearchResult<EntityAsMap> response
7980
Map<String, List<org.opensearch.client.opensearch.core.search.Suggest<EntityAsMap>>> suggest = responseBody.suggest();
8081
var pointInTimeId = responseBody.pitId();
8182
var shards = responseBody.shards();
83+
var executionDurationInMillis = responseBody.took();
8284

83-
return from(hitsMetadata, shards, scrollId, pointInTimeId, aggregations, suggest, entityCreator, jsonpMapper);
85+
return from(hitsMetadata, shards, scrollId, pointInTimeId, executionDurationInMillis, aggregations, suggest, entityCreator, jsonpMapper);
8486
}
8587

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

109-
return from(hitsMetadata, shards, scrollId, pointInTimeId, aggregations, suggest, entityCreator, jsonpMapper);
112+
return from(hitsMetadata, shards, scrollId, pointInTimeId, executionDurationInMillis, aggregations, suggest, entityCreator, jsonpMapper);
110113
}
111114

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

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

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

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

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

162-
return new SearchDocumentResponse(totalHits, totalHitsRelation, maxScore, scrollId, pointInTimeId, searchDocuments,
163-
aggregationsContainer, suggest, shardStatistics);
166+
return new SearchDocumentResponse(totalHits, totalHitsRelation, maxScore, executionDuration,
167+
scrollId, pointInTimeId, searchDocuments, aggregationsContainer, suggest, shardStatistics);
164168
}
165169

166170
private static SearchShardStatistics shardsFrom(ShardStatistics shards) {

spring-data-opensearch/src/test/java/org/opensearch/data/client/core/OpenSearchRestTemplateCallbackTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.opensearch.action.search.SearchScrollRequest;
3535
import org.opensearch.client.RequestOptions;
3636
import org.opensearch.client.RestHighLevelClient;
37+
import org.opensearch.common.unit.TimeValue;
3738
import org.opensearch.core.common.bytes.BytesArray;
3839
import org.opensearch.data.client.orhlc.OpenSearchRestTemplate;
3940

@@ -101,6 +102,7 @@ public void setUp() throws Exception {
101102
doReturn(searchResponse).when(client).search(any(SearchRequest.class), any(RequestOptions.class));
102103
doReturn(nSearchHits(2)).when(searchResponse).getHits();
103104
doReturn("scroll-id").when(searchResponse).getScrollId();
105+
doReturn(TimeValue.timeValueMillis(100)).when(searchResponse).getTook();
104106
doReturn(new BytesArray(new byte[8])).when(searchHit).getSourceRef();
105107
doReturn(new HashMap<String, Object>() {
106108
{

spring-data-opensearch/src/test/java/org/opensearch/data/client/osc/SearchDocumentResponseBuilderUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void shouldGetPhraseSuggestion() throws JSONException {
7878
.build();
7979

8080
// act
81-
final var actual = SearchDocumentResponseBuilder.from(hitsMetadata, null, null, null, null, sortProperties, null,
81+
final var actual = SearchDocumentResponseBuilder.from(hitsMetadata, null, null, null, 0, null, sortProperties, null,
8282
jsonpMapper);
8383

8484
// assert
@@ -151,7 +151,7 @@ void shouldGetShardStatisticsInfo() {
151151

152152
// act
153153
SearchDocumentResponse response = SearchDocumentResponseBuilder.from(hitsMetadata, shards, null, null,
154-
null, null, null, jsonpMapper);
154+
0, null, null, null, jsonpMapper);
155155

156156
// assert
157157
SearchShardStatistics shardStatistics = response.getSearchShardStatistics();

spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.junit.jupiter.api.DisplayName;
3838
import org.junit.jupiter.api.Order;
3939
import org.junit.jupiter.api.Test;
40+
import org.opensearch.data.client.EnabledIfOpenSearchVersion;
4041
import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration;
4142
import org.springframework.beans.factory.annotation.Autowired;
4243
import org.springframework.context.annotation.Bean;
@@ -92,6 +93,13 @@ void setUp() {
9293
void cleanup() {
9394
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete();
9495
}
96+
97+
@Test
98+
@EnabledIfOpenSearchVersion(onOrAfter = "2.15.0", reason = "https://github.com/opensearch-project/OpenSearch/issues/5639")
99+
public void shouldSupportAllTypes() {
100+
IndexOperations indexOperations = operations.indexOps(EntityWithAllTypes.class);
101+
indexOperations.createWithMapping();
102+
}
95103

96104
@Test
97105
public void shouldNotFailOnCircularReference() {
@@ -853,7 +861,7 @@ private static class EntityWithAllTypes {
853861
@Nullable
854862
@Field(type = FieldType.Percolator) String percolatorField;
855863
@Nullable
856-
@Field(type = FieldType.Flattened) String flattenedField;
864+
@Field(type = FieldType.Flattened, mappedTypeName = "flat_object") String flattenedField;
857865
@Nullable
858866
@Field(type = FieldType.Search_As_You_Type) String searchAsYouTypeField;
859867
@Nullable
@@ -862,8 +870,6 @@ private static class EntityWithAllTypes {
862870
@Field(type = FieldType.Rank_Features) String rankFeaturesField;
863871
@Nullable
864872
@Field(type = FieldType.Wildcard) String wildcardField;
865-
@Nullable
866-
@Field(type = FieldType.Dense_Vector, dims = 1) String denseVectorField;
867873
}
868874
// endregion
869875
}

version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=1.5.5
1+
version=1.6.0

0 commit comments

Comments
 (0)