committed by
GitHub
parent
ff381c63b6
commit
11a6430a90
@@ -45,7 +45,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.annotations.InnerField;
|
||||
import org.springframework.data.elasticsearch.annotations.MultiField;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.GetQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ElasticsearchRestTemplateTests extends ElasticsearchTemplateTests {
|
||||
indexRequest.source("{}", XContentType.JSON);
|
||||
UpdateQuery updateQuery = new UpdateQueryBuilder().withId(randomNumeric(5)).withIndexRequest(indexRequest).build();
|
||||
assertThatThrownBy(() -> {
|
||||
elasticsearchTemplate.update(updateQuery, index);
|
||||
operations.update(updateQuery, index);
|
||||
}).isInstanceOf(ElasticsearchStatusException.class);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
|
||||
@@ -59,7 +60,7 @@ public class ElasticsearchTransportTemplateTests extends ElasticsearchTemplateTe
|
||||
indexRequest.source("{}", XContentType.JSON);
|
||||
UpdateQuery updateQuery = new UpdateQueryBuilder().withId(randomNumeric(5)).withIndexRequest(indexRequest).build();
|
||||
assertThatThrownBy(() -> {
|
||||
elasticsearchTemplate.update(updateQuery, index);
|
||||
operations.update(updateQuery, index);
|
||||
}).isInstanceOf(DocumentMissingException.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.elasticsearch.core;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
|
||||
/**
|
||||
* @author Peter-Josef Meisch
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||
|
||||
@@ -24,6 +24,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.InnerField;
|
||||
import org.springframework.data.elasticsearch.annotations.MultiField;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.ResultsExtractor;
|
||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.elasticsearch.search.suggest.SuggestBuilder;
|
||||
import org.elasticsearch.search.suggest.SuggestBuilders;
|
||||
import org.elasticsearch.search.suggest.SuggestionBuilder;
|
||||
import org.elasticsearch.search.suggest.completion.CompletionSuggestion;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -35,7 +36,8 @@ import org.springframework.data.elasticsearch.annotations.CompletionField;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.IndexOperations;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
@@ -60,9 +62,17 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
|
||||
@Autowired private ElasticsearchOperations operations;
|
||||
|
||||
private void loadCompletionObjectEntities() {
|
||||
IndexOperations indexOperations;
|
||||
|
||||
IndexInitializer.init(operations, CompletionEntity.class);
|
||||
@BeforeEach
|
||||
private void setup() {
|
||||
indexOperations = operations.getIndexOperations();
|
||||
|
||||
IndexInitializer.init(indexOperations, CompletionEntity.class);
|
||||
IndexInitializer.init(indexOperations, AnnotatedCompletionEntity.class);
|
||||
}
|
||||
|
||||
private void loadCompletionObjectEntities() {
|
||||
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(
|
||||
@@ -80,8 +90,6 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
|
||||
private void loadAnnotatedCompletionObjectEntities() {
|
||||
|
||||
IndexInitializer.init(operations, AnnotatedCompletionEntity.class);
|
||||
|
||||
NonDocumentEntity nonDocumentEntity = new NonDocumentEntity();
|
||||
nonDocumentEntity.setSomeField1("foo");
|
||||
nonDocumentEntity.setSomeField2("bar");
|
||||
@@ -103,8 +111,6 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
|
||||
private void loadAnnotatedCompletionObjectEntitiesWithWeights() {
|
||||
|
||||
IndexInitializer.init(operations, AnnotatedCompletionEntity.class);
|
||||
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("1").name("Mewes Kochheim1")
|
||||
.suggest(new String[] { "Mewes Kochheim1" }, 4).buildIndex());
|
||||
@@ -120,17 +126,6 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
operations.refresh(AnnotatedCompletionEntity.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPutMappingForGivenEntity() throws Exception {
|
||||
|
||||
// given
|
||||
Class entity = CompletionEntity.class;
|
||||
operations.createIndex(entity);
|
||||
|
||||
// when
|
||||
assertThat(operations.putMapping(entity)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindSuggestionsForGivenCriteriaQueryUsingCompletionEntity() {
|
||||
|
||||
@@ -164,7 +159,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
// when
|
||||
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
|
||||
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
|
||||
IndexCoordinates.of("test-index-core-completion").withTypes("completion-type"));
|
||||
IndexCoordinates.of("test-index-annotated-completion").withTypes("annotated-completion-type"));
|
||||
CompletionSuggestion completionSuggestion = suggestResponse.getSuggest().getSuggestion("test-suggest");
|
||||
List<CompletionSuggestion.Entry.Option> options = completionSuggestion.getEntries().get(0).getOptions();
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.elasticsearch.search.suggest.completion.CompletionSuggestion;
|
||||
import org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder;
|
||||
import org.elasticsearch.search.suggest.completion.context.CategoryQueryContext;
|
||||
import org.elasticsearch.search.suggest.completion.context.ContextMapping;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -43,7 +44,8 @@ import org.springframework.data.elasticsearch.annotations.CompletionField;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.IndexOperations;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
@@ -64,9 +66,18 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
|
||||
|
||||
@Autowired private ElasticsearchOperations operations;
|
||||
|
||||
private IndexOperations indexOperations;
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
indexOperations = operations.getIndexOperations();
|
||||
|
||||
indexOperations.deleteIndex(ContextCompletionEntity.class);
|
||||
}
|
||||
|
||||
private void loadContextCompletionObjectEntities() {
|
||||
|
||||
IndexInitializer.init(operations, ContextCompletionEntity.class);
|
||||
IndexInitializer.init(indexOperations, ContextCompletionEntity.class);
|
||||
|
||||
NonDocumentEntity nonDocumentEntity = new NonDocumentEntity();
|
||||
nonDocumentEntity.setSomeField1("foo");
|
||||
@@ -99,17 +110,6 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
|
||||
operations.refresh(ContextCompletionEntity.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPutMappingForGivenEntity() throws Exception {
|
||||
|
||||
// given
|
||||
Class<?> entity = ContextCompletionEntity.class;
|
||||
operations.createIndex(entity);
|
||||
|
||||
// when
|
||||
assertThat(operations.putMapping(entity)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAES-536
|
||||
public void shouldFindSuggestionsForGivenCriteriaQueryUsingContextCompletionEntityOfMongo() {
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.GeoPointField;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.IndexOperations;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.Criteria;
|
||||
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||
@@ -75,11 +76,15 @@ public class ElasticsearchTemplateGeoTests {
|
||||
|
||||
@Autowired private ElasticsearchOperations operations;
|
||||
|
||||
private IndexOperations indexOperations;
|
||||
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
IndexInitializer.init(operations, AuthorMarkerEntity.class);
|
||||
IndexInitializer.init(operations, LocationMarkerEntity.class);
|
||||
indexOperations = operations.getIndexOperations();
|
||||
|
||||
IndexInitializer.init(indexOperations, AuthorMarkerEntity.class);
|
||||
IndexInitializer.init(indexOperations, LocationMarkerEntity.class);
|
||||
}
|
||||
|
||||
private void loadClassBaseEntities() {
|
||||
@@ -125,17 +130,6 @@ public class ElasticsearchTemplateGeoTests {
|
||||
operations.refresh(LocationMarkerEntity.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPutMappingForGivenEntityWithGeoLocation() throws Exception {
|
||||
|
||||
// given
|
||||
Class<?> entity = AuthorMarkerEntity.class;
|
||||
operations.createIndex(entity);
|
||||
|
||||
// when
|
||||
assertThat(operations.putMapping(entity)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindAuthorMarkersInRangeForGivenCriteriaQuery() {
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.elasticsearch.annotations.*;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.completion.Completion;
|
||||
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.Score;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexOperations;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
@@ -57,15 +58,18 @@ public class DynamicIndexEntityTests {
|
||||
@Autowired private DynamicIndexRepository repository;
|
||||
|
||||
@Autowired private ElasticsearchOperations operations;
|
||||
private IndexOperations indexOperations;
|
||||
|
||||
@Autowired private IndexNameProvider indexNameProvider;
|
||||
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
|
||||
indexOperations = operations.getIndexOperations();
|
||||
|
||||
deleteIndexes();
|
||||
operations.createIndex("index1");
|
||||
operations.createIndex("index2");
|
||||
indexOperations.createIndex("index1");
|
||||
indexOperations.createIndex("index2");
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@@ -75,8 +79,8 @@ public class DynamicIndexEntityTests {
|
||||
|
||||
private void deleteIndexes() {
|
||||
|
||||
operations.deleteIndex("index1");
|
||||
operations.deleteIndex("index2");
|
||||
indexOperations.deleteIndex("index1");
|
||||
indexOperations.deleteIndex("index2");
|
||||
}
|
||||
|
||||
@Test // DATAES-456
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.repositories.nondocument;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
public class NonDocumentEntityTests {
|
||||
|
||||
@Test
|
||||
public void shouldNotInitialiseRepositoryWithNonDocument() {
|
||||
// when
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/repository-non-document-entity.xml");
|
||||
assertThatThrownBy(() -> {
|
||||
ctx.getBean(NonDocumentEntityRepository.class);
|
||||
}).isInstanceOf(BeanCreationException.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
static class NonDocumentEntity {
|
||||
|
||||
@Id private String someId;
|
||||
private String someField1;
|
||||
private String someField2;
|
||||
|
||||
public String getSomeField1() {
|
||||
return someField1;
|
||||
}
|
||||
|
||||
public void setSomeField1(String someField1) {
|
||||
this.someField1 = someField1;
|
||||
}
|
||||
|
||||
public String getSomeField2() {
|
||||
return someField2;
|
||||
}
|
||||
|
||||
public void setSomeField2(String someField2) {
|
||||
this.someField2 = someField2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Lazy
|
||||
interface NonDocumentEntityRepository extends ElasticsearchRepository<NonDocumentEntity, String> {}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Mapping;
|
||||
import org.springframework.data.elasticsearch.annotations.Setting;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Mapping;
|
||||
import org.springframework.data.elasticsearch.annotations.Setting;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.elasticsearch.utils;
|
||||
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.IndexOperations;
|
||||
|
||||
/**
|
||||
* Utility to initialize indexes.
|
||||
@@ -31,9 +32,24 @@ public class IndexInitializer {
|
||||
*
|
||||
* @param operations
|
||||
* @param clazz
|
||||
* @deprecated since 4.0, use {@link IndexInitializer#init(IndexOperations, Class)}
|
||||
*/
|
||||
public static void init(ElasticsearchOperations operations, Class<?> clazz) {
|
||||
|
||||
operations.getIndexOperations().deleteIndex(clazz);
|
||||
operations.getIndexOperations().createIndex(clazz);
|
||||
operations.getIndexOperations().putMapping(clazz);
|
||||
operations.getIndexOperations().refresh(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a fresh index with mappings for {@link Class}. Drops the index if it exists before creation.
|
||||
*
|
||||
* @param operations
|
||||
* @param clazz
|
||||
*/
|
||||
public static void init(IndexOperations operations, Class<?> clazz) {
|
||||
|
||||
operations.deleteIndex(clazz);
|
||||
operations.createIndex(clazz);
|
||||
operations.putMapping(clazz);
|
||||
|
||||
Reference in New Issue
Block a user