mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-21 11:32:12 +00:00
Adapt to Elasticsearch client fix (ES client issue 286).
Original Pull Request #2306 Closes #2165
This commit is contained in:
parent
eabde9c543
commit
b4fe01d09b
@ -402,7 +402,6 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
|
|||||||
settingsParameter.shards = 1;
|
settingsParameter.shards = 1;
|
||||||
settingsParameter.replicas = 1;
|
settingsParameter.replicas = 1;
|
||||||
settingsParameter.refreshIntervall = "1s";
|
settingsParameter.refreshIntervall = "1s";
|
||||||
settingsParameter.indexStoreType = "fs";
|
|
||||||
|
|
||||||
if (settingAnnotation != null) {
|
if (settingAnnotation != null) {
|
||||||
processSettingAnnotation(settingAnnotation, settingsParameter);
|
processSettingAnnotation(settingAnnotation, settingsParameter);
|
||||||
@ -516,7 +515,7 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
|
|||||||
index.append("refresh_interval", refreshIntervall);
|
index.append("refresh_interval", refreshIntervall);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexStoreType != null) {
|
if (indexStoreType != null && !"fs".equals(indexStoreType)) {
|
||||||
index.append("store", new Settings().append("type", indexStoreType));
|
index.append("store", new Settings().append("type", indexStoreType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
|||||||
|
|
||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||||
import co.elastic.clients.elasticsearch._types.FieldValue;
|
import co.elastic.clients.elasticsearch._types.FieldValue;
|
||||||
import co.elastic.clients.elasticsearch._types.Script;
|
|
||||||
import co.elastic.clients.elasticsearch._types.mapping.RuntimeField;
|
|
||||||
import co.elastic.clients.elasticsearch._types.mapping.RuntimeFieldType;
|
|
||||||
import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
|
import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
|
||||||
import co.elastic.clients.elasticsearch.cluster.HealthRequest;
|
import co.elastic.clients.elasticsearch.cluster.HealthRequest;
|
||||||
import co.elastic.clients.elasticsearch.cluster.HealthResponse;
|
import co.elastic.clients.elasticsearch.cluster.HealthResponse;
|
||||||
@ -30,6 +27,8 @@ import co.elastic.clients.elasticsearch.core.IndexResponse;
|
|||||||
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
||||||
import co.elastic.clients.elasticsearch.core.search.ResponseBody;
|
import co.elastic.clients.elasticsearch.core.search.ResponseBody;
|
||||||
import co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient;
|
import co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient;
|
||||||
|
import co.elastic.clients.elasticsearch.indices.GetIndicesSettingsRequest;
|
||||||
|
import co.elastic.clients.elasticsearch.indices.GetIndicesSettingsResponse;
|
||||||
import co.elastic.clients.elasticsearch.indices.IndexSettings;
|
import co.elastic.clients.elasticsearch.indices.IndexSettings;
|
||||||
import co.elastic.clients.transport.ElasticsearchTransport;
|
import co.elastic.clients.transport.ElasticsearchTransport;
|
||||||
import co.elastic.clients.transport.TransportOptions;
|
import co.elastic.clients.transport.TransportOptions;
|
||||||
@ -85,30 +84,12 @@ public class DevTests {
|
|||||||
void someTest() throws IOException {
|
void someTest() throws IOException {
|
||||||
|
|
||||||
ElasticsearchClient client = imperativeElasticsearchClient;
|
ElasticsearchClient client = imperativeElasticsearchClient;
|
||||||
|
ElasticsearchIndicesClient indicesClient = client.indices();
|
||||||
|
|
||||||
String index = "testindex";
|
indicesClient.create(b -> b.index("testindex"));
|
||||||
|
|
||||||
var p = new Product("p1", 42.0);
|
GetIndicesSettingsResponse getIndicesSettingsResponse = indicesClient
|
||||||
|
.getSettings(GetIndicesSettingsRequest.of(b -> b.index("testindex").includeDefaults(true)));
|
||||||
client.index(ir -> ir //
|
|
||||||
.index(index)//
|
|
||||||
.document(p));
|
|
||||||
|
|
||||||
client.indices().flush(f -> f.index(index));
|
|
||||||
|
|
||||||
RuntimeField runtimeField = RuntimeField.of(rf -> rf //
|
|
||||||
.type(RuntimeFieldType.Double) //
|
|
||||||
.script(Script.of(s -> s //
|
|
||||||
.inline(i -> i. //
|
|
||||||
source("emit(doc['price'].value * 1.19)") //
|
|
||||||
) //
|
|
||||||
)) //
|
|
||||||
); //
|
|
||||||
|
|
||||||
client.search(sr -> sr //
|
|
||||||
.index(index) //
|
|
||||||
.runtimeMappings("priceWithTax", runtimeField), //
|
|
||||||
Person.class); //
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ReactiveClient {
|
static class ReactiveClient {
|
||||||
@ -371,7 +352,7 @@ public class DevTests {
|
|||||||
|
|
||||||
private ClientConfiguration clientConfiguration() {
|
private ClientConfiguration clientConfiguration() {
|
||||||
return ClientConfiguration.builder() //
|
return ClientConfiguration.builder() //
|
||||||
.connectedTo("thranduil.local.:9200")//
|
.connectedTo("localhost:9200")//
|
||||||
.withBasicAuth("elastic", "hcraescitsale").withProxy("localhost:8080") //
|
.withBasicAuth("elastic", "hcraescitsale").withProxy("localhost:8080") //
|
||||||
.withHeaders(() -> {
|
.withHeaders(() -> {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
@ -91,11 +91,6 @@ public class ElasticsearchELCIntegrationTests extends ElasticsearchIntegrationTe
|
|||||||
e -> assertThat(e.getId()).isEqualTo("2"));
|
e -> assertThat(e.getId()).isEqualTo("2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean newElasticsearchClient() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Query queryWithIds(String... ids) {
|
protected Query queryWithIds(String... ids) {
|
||||||
return ELCQueries.queryWithIds(ids);
|
return ELCQueries.queryWithIds(ids);
|
||||||
|
@ -48,7 +48,6 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.DisabledIf;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
@ -60,7 +59,6 @@ import org.springframework.data.annotation.Version;
|
|||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.elasticsearch.NewElasticsearchClientDevelopment;
|
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||||
@ -116,7 +114,7 @@ import org.springframework.lang.Nullable;
|
|||||||
* @author Sijia Liu
|
* @author Sijia Liu
|
||||||
*/
|
*/
|
||||||
@SpringIntegrationTest
|
@SpringIntegrationTest
|
||||||
public abstract class ElasticsearchIntegrationTests implements NewElasticsearchClientDevelopment {
|
public abstract class ElasticsearchIntegrationTests {
|
||||||
|
|
||||||
static final Integer INDEX_MAX_RESULT_WINDOW = 10_000;
|
static final Integer INDEX_MAX_RESULT_WINDOW = 10_000;
|
||||||
|
|
||||||
@ -2782,7 +2780,6 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
|
|||||||
assertThat(settings).doesNotContainKey("index.max_result_window");
|
assertThat(settings).doesNotContainKey("index.max_result_window");
|
||||||
}
|
}
|
||||||
|
|
||||||
@DisabledIf(value = "newElasticsearchClient", disabledReason = "todo #2165, ES issue 286")
|
|
||||||
@Test // DATAES-709
|
@Test // DATAES-709
|
||||||
public void shouldIncludeDefaultsOnGetIndexSettings() {
|
public void shouldIncludeDefaultsOnGetIndexSettings() {
|
||||||
|
|
||||||
|
@ -57,11 +57,6 @@ public class ReactiveElasticsearchELCIntegrationTests extends ReactiveElasticsea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean newElasticsearchClient() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Query getTermsAggsQuery(String aggsName, String aggsField) {
|
protected Query getTermsAggsQuery(String aggsName, String aggsField) {
|
||||||
return ELCQueries.getTermsAggsQuery(aggsName, aggsField);
|
return ELCQueries.getTermsAggsQuery(aggsName, aggsField);
|
||||||
|
@ -46,7 +46,6 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.DisabledIf;
|
|
||||||
import org.skyscreamer.jsonassert.JSONAssert;
|
import org.skyscreamer.jsonassert.JSONAssert;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
@ -58,7 +57,6 @@ import org.springframework.data.annotation.Version;
|
|||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.elasticsearch.NewElasticsearchClientDevelopment;
|
|
||||||
import org.springframework.data.elasticsearch.RestStatusException;
|
import org.springframework.data.elasticsearch.RestStatusException;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
@ -96,7 +94,7 @@ import org.springframework.util.StringUtils;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("SpringJavaAutowiredMembersInspection")
|
@SuppressWarnings("SpringJavaAutowiredMembersInspection")
|
||||||
@SpringIntegrationTest
|
@SpringIntegrationTest
|
||||||
public abstract class ReactiveElasticsearchIntegrationTests implements NewElasticsearchClientDevelopment {
|
public abstract class ReactiveElasticsearchIntegrationTests {
|
||||||
|
|
||||||
@Autowired private ReactiveElasticsearchOperations operations;
|
@Autowired private ReactiveElasticsearchOperations operations;
|
||||||
@Autowired private IndexNameProvider indexNameProvider;
|
@Autowired private IndexNameProvider indexNameProvider;
|
||||||
@ -1065,7 +1063,6 @@ public abstract class ReactiveElasticsearchIntegrationTests implements NewElasti
|
|||||||
}).verifyComplete();
|
}).verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DisabledIf(value = "newElasticsearchClient", disabledReason = "todo #2165, ES issue 286")
|
|
||||||
@Test // #1646, #1718
|
@Test // #1646, #1718
|
||||||
@DisplayName("should return a list of info for specific index")
|
@DisplayName("should return a list of info for specific index")
|
||||||
void shouldReturnInformationListOfAllIndices() {
|
void shouldReturnInformationListOfAllIndices() {
|
||||||
|
@ -36,9 +36,4 @@ public class IndexOperationsELCIntegrationTests extends IndexOperationsIntegrati
|
|||||||
return new IndexNameProvider("indexoperations");
|
return new IndexNameProvider("indexoperations");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean newElasticsearchClient() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,9 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.DisabledIf;
|
|
||||||
import org.skyscreamer.jsonassert.JSONAssert;
|
import org.skyscreamer.jsonassert.JSONAssert;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.NewElasticsearchClientDevelopment;
|
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Mapping;
|
import org.springframework.data.elasticsearch.annotations.Mapping;
|
||||||
import org.springframework.data.elasticsearch.annotations.Setting;
|
import org.springframework.data.elasticsearch.annotations.Setting;
|
||||||
@ -52,7 +50,7 @@ import org.springframework.lang.Nullable;
|
|||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@SpringIntegrationTest
|
@SpringIntegrationTest
|
||||||
public abstract class IndexOperationsIntegrationTests implements NewElasticsearchClientDevelopment {
|
public abstract class IndexOperationsIntegrationTests {
|
||||||
|
|
||||||
@Autowired private ElasticsearchOperations operations;
|
@Autowired private ElasticsearchOperations operations;
|
||||||
private IndexOperations indexOperations;
|
private IndexOperations indexOperations;
|
||||||
@ -73,7 +71,6 @@ public abstract class IndexOperationsIntegrationTests implements NewElasticsearc
|
|||||||
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete();
|
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DisabledIf(value = "newElasticsearchClient", disabledReason = "todo #2165, ES issue 286")
|
|
||||||
@Test // #1646, #1718
|
@Test // #1646, #1718
|
||||||
@DisplayName("should return a list of info for specific index")
|
@DisplayName("should return a list of info for specific index")
|
||||||
void shouldReturnInformationList() throws JSONException {
|
void shouldReturnInformationList() throws JSONException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user