Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59f3a6b120 | |||
| e534e952a1 | |||
| 868a9d049a | |||
| 28727c6b36 | |||
| 89528e0e59 | |||
| 42e49e8ff7 | |||
| b52fc2f0d7 | |||
| 1923721ebf | |||
| 8834cbfe03 | |||
| 2dabb2f89f |
+2
-2
@@ -1,3 +1,3 @@
|
||||
#Mon Jan 30 10:47:25 CET 2023
|
||||
#Mon Feb 20 11:59:41 CET 2023
|
||||
wrapperUrl=https\://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
|
||||
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
|
||||
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-elasticsearch</artifactId>
|
||||
<version>5.0.2</version>
|
||||
<version>5.0.4</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.data.build</groupId>
|
||||
<artifactId>spring-data-parent</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.0.4</version>
|
||||
</parent>
|
||||
|
||||
<name>Spring Data Elasticsearch</name>
|
||||
@@ -18,7 +18,7 @@
|
||||
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
||||
|
||||
<properties>
|
||||
<springdata.commons>3.0.2</springdata.commons>
|
||||
<springdata.commons>3.0.4</springdata.commons>
|
||||
|
||||
<!-- version of the RestHighLevelClient -->
|
||||
<elasticsearch-rhlc>7.17.9</elasticsearch-rhlc>
|
||||
|
||||
+10
-27
@@ -78,6 +78,7 @@ import jakarta.json.stream.JsonParser;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
@@ -176,14 +177,12 @@ class RequestConverter {
|
||||
createRequestBuilder.index(indexCoordinates.getIndexName());
|
||||
|
||||
// note: the new client does not support the index.storeType anymore
|
||||
String settingsJson = Document.from(settings).toJson();
|
||||
IndexSettings indexSettings = fromJson(settingsJson, IndexSettings._DESERIALIZER);
|
||||
createRequestBuilder.settings(indexSettings);
|
||||
createRequestBuilder.settings(IndexSettings.of(b -> b //
|
||||
.withJson(new StringReader(Document.from(settings).toJson()))));
|
||||
|
||||
if (mapping != null) {
|
||||
String mappingJson = mapping.toJson();
|
||||
TypeMapping typeMapping = fromJson(mappingJson, TypeMapping._DESERIALIZER);
|
||||
createRequestBuilder.mappings(typeMapping);
|
||||
createRequestBuilder.mappings(TypeMapping.of(b -> b //
|
||||
.withJson(new StringReader(mapping.toJson()))));
|
||||
}
|
||||
|
||||
return createRequestBuilder.build();
|
||||
@@ -275,11 +274,12 @@ class RequestConverter {
|
||||
Assert.notNull(indexCoordinates, "indexCoordinates must not be null");
|
||||
Assert.notNull(mapping, "mapping must not be null");
|
||||
|
||||
PutMappingRequest.Builder builder = new PutMappingRequest.Builder();
|
||||
builder.index(Arrays.asList(indexCoordinates.getIndexNames()));
|
||||
addPropertiesToMapping(builder, mapping);
|
||||
PutMappingRequest request = new PutMappingRequest.Builder() //
|
||||
.withJson(new StringReader(mapping.toJson())) //
|
||||
.index(Arrays.asList(indexCoordinates.getIndexNames())) //
|
||||
.build();
|
||||
|
||||
return builder.build();
|
||||
return request;
|
||||
}
|
||||
|
||||
public GetMappingRequest indicesGetMappingRequest(IndexCoordinates indexCoordinates) {
|
||||
@@ -289,23 +289,6 @@ class RequestConverter {
|
||||
return new GetMappingRequest.Builder().index(Arrays.asList(indexCoordinates.getIndexNames())).build();
|
||||
}
|
||||
|
||||
private void addPropertiesToMapping(PutMappingRequest.Builder builder, Document mapping) {
|
||||
Object properties = mapping.get("properties");
|
||||
|
||||
if (properties != null) {
|
||||
|
||||
if (properties instanceof Map) {
|
||||
Map<String, Property> propertiesMap = new HashMap<>();
|
||||
// noinspection unchecked
|
||||
((Map<String, Object>) properties).forEach((key, value) -> {
|
||||
Property property = getProperty(value);
|
||||
propertiesMap.put(key, property);
|
||||
});
|
||||
builder.properties(propertiesMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Property getProperty(Object value) {
|
||||
// noinspection SpellCheckingInspection
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Spring Data Elasticsearch 5.0.2 (2022.0.2)
|
||||
Spring Data Elasticsearch 5.0.4 (2022.0.4)
|
||||
Copyright (c) [2013-2021] Pivotal Software, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
@@ -18,3 +18,5 @@ conditions of the subcomponent's license, as noted in the LICENSE file.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+38
-3
@@ -43,7 +43,16 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.NewElasticsearchClientDevelopment;
|
||||
import org.springframework.data.elasticsearch.annotations.*;
|
||||
import org.springframework.data.elasticsearch.annotations.DateFormat;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Dynamic;
|
||||
import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.annotations.InnerField;
|
||||
import org.springframework.data.elasticsearch.annotations.Mapping;
|
||||
import org.springframework.data.elasticsearch.annotations.MultiField;
|
||||
import org.springframework.data.elasticsearch.annotations.Setting;
|
||||
import org.springframework.data.elasticsearch.annotations.TermVector;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexOperations;
|
||||
import org.springframework.data.elasticsearch.core.MappingContextBaseTests;
|
||||
@@ -205,11 +214,37 @@ public abstract class MappingBuilderIntegrationTests extends MappingContextBaseT
|
||||
}
|
||||
|
||||
@Test // #1767
|
||||
@DisplayName("should write dynamic mapping annotations")
|
||||
void shouldWriteDynamicMappingAnnotations() {
|
||||
@DisplayName("should write dynamic mapping annotations on create")
|
||||
void shouldWriteDynamicMappingAnnotationsOnCreate() {
|
||||
|
||||
IndexOperations indexOps = operations.indexOps(DynamicMappingAnnotationEntity.class);
|
||||
indexOps.createWithMapping();
|
||||
|
||||
var mapping = indexOps.getMapping();
|
||||
var dynamic = mapping.get("dynamic");
|
||||
if (dynamic instanceof String s) {
|
||||
assertThat(dynamic).isEqualTo("false");
|
||||
} else {
|
||||
assertThat(mapping.get("dynamic")).isEqualTo(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test // #2478
|
||||
@DisplayName("should write dynamic mapping annotations on put")
|
||||
void shouldWriteDynamicMappingAnnotationsOnPut() {
|
||||
|
||||
IndexOperations indexOps = operations.indexOps(DynamicMappingAnnotationEntity.class);
|
||||
indexOps.create();
|
||||
|
||||
indexOps.putMapping();
|
||||
|
||||
var mapping = indexOps.getMapping();
|
||||
var dynamic = mapping.get("dynamic");
|
||||
if (dynamic instanceof String s) {
|
||||
assertThat(dynamic).isEqualTo("false");
|
||||
} else {
|
||||
assertThat(mapping.get("dynamic")).isEqualTo(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test // #1871
|
||||
|
||||
Reference in New Issue
Block a user