mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-05-30 16:52:11 +00:00
parent
ebac4c097c
commit
843fd4db85
22
pom.xml
22
pom.xml
@ -226,6 +226,22 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
we don't use lombok in Spring Data Elasticsearch anymore. But the dependency is set in the parent project, and so the
|
||||
lombok compiler stuff is executed regardless of the fact that we don't need it.
|
||||
On AdoptOpenJdk 16.0.0 this leads to an error, so the project does not build.
|
||||
Therefore we replace lombok with a jar - that just contains an empty file - that lives in a local maven repository in
|
||||
src/test/resources/local-maven-repo/
|
||||
It was installed with
|
||||
mvn deploy:deploy-file -DgroupId=org.projectlombok -DartifactId=lombok -Dversion=999999 -Durl=file:./src/test/resources/local-maven-repo/ -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile=path/to/empty.jar
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>999999</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.openwebbeans.test</groupId>
|
||||
<artifactId>cditest-owb</artifactId>
|
||||
@ -435,6 +451,12 @@
|
||||
<id>spring-libs-snapshot</id>
|
||||
<url>https://repo.spring.io/libs-snapshot</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>local-maven-repo</id>
|
||||
<url>file:///${project.basedir}/src/test/resources/local-maven-repo</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
|
@ -19,10 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -53,6 +49,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -384,82 +381,238 @@ public class NestedObjectTests {
|
||||
assertThat(books.getSearchHit(0).getContent().getId()).isEqualTo(book2.getId());
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Document(indexName = "test-index-book-nested-objects", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||
searchAnalyzer = "standard") }) private String description;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(@Nullable Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<Integer, Collection<String>> getBuckets() {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
public void setBuckets(@Nullable Map<Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-person", replicas = 0, refreshInterval = "-1")
|
||||
static class Person {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Nested) private List<Car> car;
|
||||
@Nullable @Field(type = FieldType.Nested, includeInParent = true) private List<Book> books;
|
||||
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private String name;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Nested) private List<Car> car;
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Nested, includeInParent = true) private List<Book> books;
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Car> getCar() {
|
||||
return car;
|
||||
}
|
||||
|
||||
public void setCar(@Nullable List<Car> car) {
|
||||
this.car = car;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Book> getBooks() {
|
||||
return books;
|
||||
}
|
||||
|
||||
public void setBooks(@Nullable List<Book> books) {
|
||||
this.books = books;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Car {
|
||||
@Nullable private String name;
|
||||
@Nullable private String model;
|
||||
|
||||
private String name;
|
||||
private String model;
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
@Data
|
||||
@Document(indexName = "test-index-person-multiple-level-nested", replicas = 0, refreshInterval = "-1")
|
||||
static class PersonMultipleLevelNested {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Nested) private List<GirlFriend> girlFriends;
|
||||
@Nullable @Field(type = FieldType.Nested) private List<Car> cars;
|
||||
@Nullable @Field(type = FieldType.Nested, includeInParent = true) private List<Car> bestCars;
|
||||
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private String name;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Nested) private List<GirlFriend> girlFriends;
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Nested) private List<Car> cars;
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Nested, includeInParent = true) private List<Car> bestCars;
|
||||
@Nullable
|
||||
public List<GirlFriend> getGirlFriends() {
|
||||
return girlFriends;
|
||||
}
|
||||
|
||||
public void setGirlFriends(@Nullable List<GirlFriend> girlFriends) {
|
||||
this.girlFriends = girlFriends;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Car> getCars() {
|
||||
return cars;
|
||||
}
|
||||
|
||||
public void setCars(@Nullable List<Car> cars) {
|
||||
this.cars = cars;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Car> getBestCars() {
|
||||
return bestCars;
|
||||
}
|
||||
|
||||
public void setBestCars(@Nullable List<Car> bestCars) {
|
||||
this.bestCars = bestCars;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
@Data
|
||||
static class GirlFriend {
|
||||
@Nullable private String name;
|
||||
@Nullable private String type;
|
||||
@Nullable @Field(type = FieldType.Nested) private List<Car> cars;
|
||||
|
||||
private String name;
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private String type;
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Nested) private List<Car> cars;
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Car> getCars() {
|
||||
return cars;
|
||||
}
|
||||
|
||||
public void setCars(@Nullable List<Car> cars) {
|
||||
this.cars = cars;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
@Data
|
||||
static class Author {
|
||||
@Nullable private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,10 +18,6 @@ package org.springframework.data.elasticsearch.annotations;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.skyscreamer.jsonassert.JSONAssert.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
@ -41,6 +37,7 @@ import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersiste
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Peter-Josef Meisch
|
||||
@ -144,14 +141,47 @@ public class ComposableAnnotationsUnitTest {
|
||||
public @interface TextKeywordField {
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@DocumentNoCreate(indexName = "test-no-create")
|
||||
static class ComposedAnnotationEntity {
|
||||
@Id private String id;
|
||||
@NullValueField(name = "null-value") private String nullValue;
|
||||
@LocalDateField private LocalDate theDate;
|
||||
@TextKeywordField private String multiField;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @NullValueField(name = "null-value") private String nullValue;
|
||||
@Nullable @LocalDateField private LocalDate theDate;
|
||||
@Nullable @TextKeywordField private String multiField;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getNullValue() {
|
||||
return nullValue;
|
||||
}
|
||||
|
||||
public void setNullValue(@Nullable String nullValue) {
|
||||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LocalDate getTheDate() {
|
||||
return theDate;
|
||||
}
|
||||
|
||||
public void setTheDate(@Nullable LocalDate theDate) {
|
||||
this.theDate = theDate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMultiField() {
|
||||
return multiField;
|
||||
}
|
||||
|
||||
public void setMultiField(@Nullable String multiField) {
|
||||
this.multiField = multiField;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ package org.springframework.data.elasticsearch.client.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@ -1112,7 +1111,6 @@ public class ReactiveElasticsearchClientIntegrationTests {
|
||||
.create(true);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private String doIndex(Map<String, ?> source, String index) {
|
||||
return operations.save(source, IndexCoordinates.of(index)).block().get("id").toString();
|
||||
}
|
||||
|
@ -18,9 +18,6 @@ package org.springframework.data.elasticsearch.config.nested;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.lang.Double;
|
||||
import java.lang.Long;
|
||||
|
||||
@ -41,6 +38,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTem
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -75,20 +73,17 @@ public class EnableNestedElasticsearchRepositoriesTests {
|
||||
assertThat(nestedRepository).isNotNull();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Document(indexName = "test-index-sample-config-nested", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
private int rate;
|
||||
@ScriptedField private Double scriptedRate;
|
||||
private boolean available;
|
||||
private String highlightedMessage;
|
||||
private GeoPoint location;
|
||||
@Version private Long version;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable @ScriptedField private Double scriptedRate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable private String highlightedMessage;
|
||||
@Nullable private GeoPoint location;
|
||||
@Nullable @Version private Long version;
|
||||
}
|
||||
|
||||
interface SampleRepository extends Repository<SampleEntity, Long> {}
|
||||
|
@ -18,8 +18,6 @@ package org.springframework.data.elasticsearch.config.notnested;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.lang.Double;
|
||||
import java.lang.Long;
|
||||
import java.util.UUID;
|
||||
@ -122,33 +120,187 @@ public class EnableElasticsearchRepositoriesTests implements ApplicationContextA
|
||||
assertThat(nestedRepository).isNull();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-sample-config-not-nested", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable @ScriptedField private Double scriptedRate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable private String highlightedMessage;
|
||||
@Nullable private GeoPoint location;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
private int rate;
|
||||
@ScriptedField private Double scriptedRate;
|
||||
private boolean available;
|
||||
private String highlightedMessage;
|
||||
private GeoPoint location;
|
||||
@Version private Long version;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Double getScriptedRate() {
|
||||
return scriptedRate;
|
||||
}
|
||||
|
||||
public void setScriptedRate(@Nullable java.lang.Double scriptedRate) {
|
||||
this.scriptedRate = scriptedRate;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getHighlightedMessage() {
|
||||
return highlightedMessage;
|
||||
}
|
||||
|
||||
public void setHighlightedMessage(@Nullable String highlightedMessage) {
|
||||
this.highlightedMessage = highlightedMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable GeoPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-uuid-keyed-config-not-nested", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntityUUIDKeyed {
|
||||
@Nullable @Id private UUID id;
|
||||
@Nullable private String type;
|
||||
@Nullable @Field(type = FieldType.Text, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable @ScriptedField private Long scriptedRate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable private String highlightedMessage;
|
||||
@Nullable private GeoPoint location;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Id private UUID id;
|
||||
private String type;
|
||||
@Field(type = FieldType.Text, fielddata = true) private String message;
|
||||
private int rate;
|
||||
@ScriptedField private Long scriptedRate;
|
||||
private boolean available;
|
||||
private String highlightedMessage;
|
||||
private GeoPoint location;
|
||||
@Version private Long version;
|
||||
@Nullable
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getScriptedRate() {
|
||||
return scriptedRate;
|
||||
}
|
||||
|
||||
public void setScriptedRate(@Nullable java.lang.Long scriptedRate) {
|
||||
this.scriptedRate = scriptedRate;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getHighlightedMessage() {
|
||||
return highlightedMessage;
|
||||
}
|
||||
|
||||
public void setHighlightedMessage(@Nullable String highlightedMessage) {
|
||||
this.highlightedMessage = highlightedMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable GeoPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,6 @@ import static java.util.Collections.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
@ -443,13 +439,53 @@ abstract class AbstractElasticsearchTemplateCallbackTests {
|
||||
assertThat(iterator.next().firstname).isEqualTo("before-convert");
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class Person {
|
||||
@Nullable @Id String id;
|
||||
@Nullable String firstname;
|
||||
|
||||
@Id String id;
|
||||
String firstname;
|
||||
public Person(@Nullable String id, @Nullable String firstname) {
|
||||
this.id = id;
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(@Nullable String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (id != null ? !id.equals(person.id) : person.id != null) return false;
|
||||
return firstname != null ? firstname.equals(person.firstname) : person.firstname == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (firstname != null ? firstname.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static class ValueCapturingEntityCallback<T> {
|
||||
|
@ -21,10 +21,6 @@ import static org.skyscreamer.jsonassert.JSONAssert.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.val;
|
||||
|
||||
import java.lang.Object;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
@ -37,6 +33,7 @@ import org.elasticsearch.action.support.WriteRequest;
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.reindex.UpdateByQueryRequest;
|
||||
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
|
||||
import org.json.JSONException;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -49,6 +46,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -81,13 +79,29 @@ public class ElasticsearchRestTemplateTests extends ElasticsearchTemplateTests {
|
||||
.isInstanceOf(UncategorizedElasticsearchException.class);
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Document(indexName = "test-index-sample-core-rest-template", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@Test // DATAES-768
|
||||
@ -122,7 +136,7 @@ public class ElasticsearchRestTemplateTests extends ElasticsearchTemplateTests {
|
||||
assertThat(request.retryOnConflict()).isEqualTo(7);
|
||||
assertThat(request.timeout()).isEqualByComparingTo(TimeValue.parseTimeValue("4711s", "test"));
|
||||
assertThat(request.waitForActiveShards()).isEqualTo(ActiveShardCount.ALL);
|
||||
val fetchSourceContext = request.fetchSource();
|
||||
FetchSourceContext fetchSourceContext = request.fetchSource();
|
||||
assertThat(fetchSourceContext).isNotNull();
|
||||
assertThat(fetchSourceContext.includes()).containsExactlyInAnyOrder("incl");
|
||||
assertThat(fetchSourceContext.excludes()).containsExactlyInAnyOrder("excl");
|
||||
|
@ -23,12 +23,6 @@ import static org.springframework.data.elasticsearch.core.document.Document.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.lang.Double;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Long;
|
||||
@ -65,8 +59,6 @@ import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptType;
|
||||
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
|
||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||||
import org.elasticsearch.search.rescore.QueryRescoreMode;
|
||||
import org.elasticsearch.search.rescore.QueryRescorerBuilder;
|
||||
import org.elasticsearch.search.sort.FieldSortBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilders;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
@ -1989,8 +1981,11 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
String documentId = nextIdAsString();
|
||||
GTEVersionEntity entity = GTEVersionEntity.builder().id(documentId).name("FooBar")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
GTEVersionEntity entity = new GTEVersionEntity();
|
||||
entity.setId(documentId);
|
||||
entity.setName("FooBar");
|
||||
entity.setVersion(System.currentTimeMillis());
|
||||
|
||||
IndexQueryBuilder indexQueryBuilder = new IndexQueryBuilder().withId(documentId).withVersion(entity.getVersion())
|
||||
.withObject(entity);
|
||||
@ -3072,7 +3067,10 @@ public abstract class ElasticsearchTemplateTests {
|
||||
@Test // DATAES-714
|
||||
void shouldReturnSortFieldsInSearchHits() {
|
||||
IndexCoordinates index = IndexCoordinates.of("test-index-searchhits-entity-template");
|
||||
SearchHitsEntity entity = SearchHitsEntity.builder().id("1").number(1000L).keyword("thousands").build();
|
||||
SearchHitsEntity entity = new SearchHitsEntity();
|
||||
entity.setId("1");
|
||||
entity.setNumber(1000L);
|
||||
entity.setKeyword("thousands");
|
||||
IndexQuery indexQuery = new IndexQueryBuilder().withId(entity.getId()).withObject(entity).build();
|
||||
operations.index(indexQuery, index);
|
||||
operations.indexOps(index).refresh();
|
||||
@ -3107,10 +3105,9 @@ public abstract class ElasticsearchTemplateTests {
|
||||
@Test // DATAES-715
|
||||
void shouldReturnHighlightFieldsInSearchHit() {
|
||||
IndexCoordinates index = IndexCoordinates.of("test-index-highlight-entity-template");
|
||||
HighlightEntity entity = HighlightEntity.builder().id("1")
|
||||
.message("This message is a long text which contains the word to search for "
|
||||
+ "in two places, the first being near the beginning and the second near the end of the message")
|
||||
.build();
|
||||
HighlightEntity entity = new HighlightEntity("1",
|
||||
"This message is a long text which contains the word to search for "
|
||||
+ "in two places, the first being near the beginning and the second near the end of the message");
|
||||
IndexQuery indexQuery = new IndexQueryBuilder().withId(entity.getId()).withObject(entity).build();
|
||||
operations.index(indexQuery, index);
|
||||
operations.indexOps(index).refresh();
|
||||
@ -3140,16 +3137,14 @@ public abstract class ElasticsearchTemplateTests {
|
||||
SampleEntity entity = SampleEntity.builder() //
|
||||
.id("1") //
|
||||
.message("some message") //
|
||||
.rate(java.lang.Integer.MAX_VALUE)
|
||||
.version(System.currentTimeMillis()) //
|
||||
.rate(java.lang.Integer.MAX_VALUE).version(System.currentTimeMillis()) //
|
||||
.build();
|
||||
|
||||
// high score from rescore query
|
||||
SampleEntity entity2 = SampleEntity.builder() //
|
||||
.id("2") //
|
||||
.message("nothing") //
|
||||
.rate(1)
|
||||
.version(System.currentTimeMillis()) //
|
||||
.rate(1).version(System.currentTimeMillis()) //
|
||||
.build();
|
||||
|
||||
List<IndexQuery> indexQueries = getIndexQueries(Arrays.asList(entity, entity2));
|
||||
@ -3158,26 +3153,15 @@ public abstract class ElasticsearchTemplateTests {
|
||||
indexOperations.refresh();
|
||||
|
||||
NativeSearchQuery query = new NativeSearchQueryBuilder() //
|
||||
.withQuery(
|
||||
boolQuery().filter(existsQuery("rate")).should(termQuery("message", "message"))) //
|
||||
.withRescorerQuery(new RescorerQuery(
|
||||
new NativeSearchQueryBuilder().withQuery(
|
||||
QueryBuilders.functionScoreQuery(
|
||||
new FunctionScoreQueryBuilder.FilterFunctionBuilder[]{
|
||||
new FilterFunctionBuilder(
|
||||
new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5)
|
||||
.setWeight(1f)),
|
||||
new FilterFunctionBuilder(
|
||||
new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5)
|
||||
.setWeight(100f))}
|
||||
)
|
||||
.scoreMode(FunctionScoreQuery.ScoreMode.SUM)
|
||||
.maxBoost(80f)
|
||||
.boostMode(CombineFunction.REPLACE)
|
||||
).build()
|
||||
)
|
||||
.withScoreMode(ScoreMode.Max)
|
||||
.withWindowSize(100))
|
||||
.withQuery(boolQuery().filter(existsQuery("rate")).should(termQuery("message", "message"))) //
|
||||
.withRescorerQuery(
|
||||
new RescorerQuery(new NativeSearchQueryBuilder().withQuery(QueryBuilders
|
||||
.functionScoreQuery(new FunctionScoreQueryBuilder.FilterFunctionBuilder[] {
|
||||
new FilterFunctionBuilder(new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5).setWeight(1f)),
|
||||
new FilterFunctionBuilder(
|
||||
new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5).setWeight(100f)) })
|
||||
.scoreMode(FunctionScoreQuery.ScoreMode.SUM).maxBoost(80f).boostMode(CombineFunction.REPLACE)).build())
|
||||
.withScoreMode(ScoreMode.Max).withWindowSize(100))
|
||||
.build();
|
||||
|
||||
SearchHits<SampleEntity> searchHits = operations.search(query, SampleEntity.class, index);
|
||||
@ -3187,12 +3171,12 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
SearchHit<SampleEntity> searchHit = searchHits.getSearchHit(0);
|
||||
assertThat(searchHit.getContent().getMessage()).isEqualTo("nothing");
|
||||
//score capped to 80
|
||||
// score capped to 80
|
||||
assertThat(searchHit.getScore()).isEqualTo(80f);
|
||||
}
|
||||
|
||||
@Test
|
||||
// DATAES-738
|
||||
// DATAES-738
|
||||
void shouldSaveEntityWithIndexCoordinates() {
|
||||
String id = "42";
|
||||
SampleEntity entity = new SampleEntity();
|
||||
@ -3766,130 +3750,560 @@ public abstract class ElasticsearchTemplateTests {
|
||||
assertThat(explanation).isNotNull();
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(exclude = "score")
|
||||
@Builder
|
||||
@Document(indexName = INDEX_NAME_SAMPLE_ENTITY, replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable @ScriptedField private Double scriptedRate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable private GeoPoint location;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
private int rate;
|
||||
@ScriptedField private Double scriptedRate;
|
||||
private boolean available;
|
||||
private GeoPoint location;
|
||||
@Version private Long version;
|
||||
static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
static class Builder {
|
||||
|
||||
@Nullable private String id;
|
||||
@Nullable private String type;
|
||||
@Nullable private String message;
|
||||
@Nullable private Long version;
|
||||
@Nullable private int rate;
|
||||
@Nullable private GeoPoint location;
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder message(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder version(Long version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder rate(int rate) {
|
||||
this.rate = rate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder location(GeoPoint location) {
|
||||
this.location = location;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SampleEntity build() {
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(id);
|
||||
sampleEntity.setType(type);
|
||||
sampleEntity.setMessage(message);
|
||||
sampleEntity.setRate(rate);
|
||||
sampleEntity.setVersion(version);
|
||||
sampleEntity.setLocation(location);
|
||||
return sampleEntity;
|
||||
}
|
||||
}
|
||||
|
||||
public SampleEntity() {}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Double getScriptedRate() {
|
||||
return scriptedRate;
|
||||
}
|
||||
|
||||
public void setScriptedRate(@Nullable java.lang.Double scriptedRate) {
|
||||
this.scriptedRate = scriptedRate;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable GeoPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
SampleEntity that = (SampleEntity) o;
|
||||
|
||||
if (rate != that.rate)
|
||||
return false;
|
||||
if (available != that.available)
|
||||
return false;
|
||||
if (id != null ? !id.equals(that.id) : that.id != null)
|
||||
return false;
|
||||
if (type != null ? !type.equals(that.type) : that.type != null)
|
||||
return false;
|
||||
if (message != null ? !message.equals(that.message) : that.message != null)
|
||||
return false;
|
||||
if (scriptedRate != null ? !scriptedRate.equals(that.scriptedRate) : that.scriptedRate != null)
|
||||
return false;
|
||||
if (location != null ? !location.equals(that.location) : that.location != null)
|
||||
return false;
|
||||
return version != null ? version.equals(that.version) : that.version == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (type != null ? type.hashCode() : 0);
|
||||
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||
result = 31 * result + rate;
|
||||
result = 31 * result + (scriptedRate != null ? scriptedRate.hashCode() : 0);
|
||||
result = 31 * result + (available ? 1 : 0);
|
||||
result = 31 * result + (location != null ? location.hashCode() : 0);
|
||||
result = 31 * result + (version != null ? version.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Gad Akuka
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-uuid-keyed-core-template", replicas = 0, refreshInterval = "-1")
|
||||
private static class SampleEntityUUIDKeyed {
|
||||
@Nullable @Id private UUID id;
|
||||
@Nullable private String type;
|
||||
@Nullable @Field(type = FieldType.Text, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable @ScriptedField private Long scriptedRate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable private GeoPoint location;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Id private UUID id;
|
||||
private String type;
|
||||
@Field(type = FieldType.Text, fielddata = true) private String message;
|
||||
private int rate;
|
||||
@ScriptedField private Long scriptedRate;
|
||||
private boolean available;
|
||||
private GeoPoint location;
|
||||
@Version private Long version;
|
||||
@Nullable
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getScriptedRate() {
|
||||
return scriptedRate;
|
||||
}
|
||||
|
||||
public void setScriptedRate(@Nullable java.lang.Long scriptedRate) {
|
||||
this.scriptedRate = scriptedRate;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable GeoPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Document(indexName = "test-index-book-core-template", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||
searchAnalyzer = "standard") }) private String description;
|
||||
|
||||
public Book(@Nullable String id, @Nullable String name, @Nullable Author author,
|
||||
@Nullable Map<java.lang.Integer, Collection<String>> buckets, @Nullable String description) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.author = author;
|
||||
this.buckets = buckets;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(@Nullable Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<java.lang.Integer, Collection<String>> getBuckets() {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
public void setBuckets(@Nullable Map<java.lang.Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
static class Builder {
|
||||
@Nullable private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable private Author author;
|
||||
@Nullable private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable private String description;
|
||||
|
||||
public Builder id(@Nullable String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(@Nullable String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder author(@Nullable Author author) {
|
||||
this.author = author;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder buckets(@Nullable Map<java.lang.Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder description(@Nullable String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
Book build() {
|
||||
return new Book(id, name, author, buckets, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Author {
|
||||
private String id;
|
||||
private String name;
|
||||
@Nullable private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Document(indexName = "test-index-version-core-template", replicas = 0, refreshInterval = "-1",
|
||||
versionType = VersionType.EXTERNAL_GTE)
|
||||
private static class GTEVersionEntity {
|
||||
@Nullable @Version private Long version;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
@Version private Long version;
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Id private String id;
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
private String name;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-hetro1-core-template", replicas = 0)
|
||||
static class HetroEntity1 {
|
||||
|
||||
@Id private String id;
|
||||
private String firstName;
|
||||
@Version private Long version;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String firstName;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
HetroEntity1(String id, String firstName) {
|
||||
this.id = id;
|
||||
this.firstName = firstName;
|
||||
this.version = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(@Nullable String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-hetro2-core-template", replicas = 0)
|
||||
static class HetroEntity2 {
|
||||
|
||||
@Id private String id;
|
||||
private String lastName;
|
||||
@Version private Long version;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String lastName;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
HetroEntity2(String id, String lastName) {
|
||||
this.id = id;
|
||||
this.lastName = lastName;
|
||||
this.version = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(@Nullable String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-server-configuration", useServerConfiguration = true, shards = 10, replicas = 10,
|
||||
refreshInterval = "-1")
|
||||
private static class UseServerConfigurationEntity {
|
||||
|
||||
@Id private String id;
|
||||
private String val;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String val;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public void setVal(@Nullable String val) {
|
||||
this.val = val;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-sample-mapping", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleMappingEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||
|
||||
@Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
static class NestedEntity {
|
||||
|
||||
@ -3906,58 +4320,211 @@ public abstract class ElasticsearchTemplateTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-searchhits-entity-template")
|
||||
static class SearchHitsEntity {
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Long) Long number;
|
||||
@Field(type = FieldType.Keyword) String keyword;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Long) Long number;
|
||||
@Nullable @Field(type = FieldType.Keyword) String keyword;
|
||||
|
||||
public SearchHitsEntity() {}
|
||||
|
||||
public SearchHitsEntity(@Nullable String id, @Nullable java.lang.Long number, @Nullable String keyword) {
|
||||
this.id = id;
|
||||
this.number = number;
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(@Nullable java.lang.Long number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(@Nullable String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-highlight-entity-template")
|
||||
static class HighlightEntity {
|
||||
@Id private String id;
|
||||
private String message;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String message;
|
||||
|
||||
public HighlightEntity(@Nullable String id, @Nullable String message) {
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-optimistic-entity-template")
|
||||
static class OptimisticEntity {
|
||||
@Id private String id;
|
||||
private String message;
|
||||
private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String message;
|
||||
@Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
|
||||
return seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
|
||||
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-optimistic-and-versioned-entity-template")
|
||||
static class OptimisticAndVersionedEntity {
|
||||
@Id private String id;
|
||||
private String message;
|
||||
private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Version private Long version;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String message;
|
||||
@Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
|
||||
return seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
|
||||
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-versioned-entity-template")
|
||||
static class VersionedEntity {
|
||||
@Id private String id;
|
||||
@Version private Long version;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = INDEX_NAME_JOIN_SAMPLE_ENTITY)
|
||||
static class SampleJoinEntity {
|
||||
@Id @Field(type = Keyword) private String uuid;
|
||||
@JoinTypeRelations(relations = {
|
||||
@Nullable @Id @Field(type = Keyword) private String uuid;
|
||||
@Nullable @JoinTypeRelations(relations = {
|
||||
@JoinTypeRelation(parent = "question", children = { "answer" }) }) private JoinField<String> myJoinField;
|
||||
@Field(type = Text) private String text;
|
||||
@Nullable @Field(type = Text) private String text;
|
||||
|
||||
@Nullable
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(@Nullable String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JoinField<String> getMyJoinField() {
|
||||
return myJoinField;
|
||||
}
|
||||
|
||||
public void setMyJoinField(@Nullable JoinField<String> myJoinField) {
|
||||
this.myJoinField = myJoinField;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,6 @@ import static org.skyscreamer.jsonassert.JSONAssert.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.val;
|
||||
|
||||
import java.lang.Object;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
@ -55,6 +52,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -108,18 +106,18 @@ public class ElasticsearchTransportTemplateTests extends ElasticsearchTemplateTe
|
||||
doc.put("message", "test");
|
||||
org.springframework.data.elasticsearch.core.document.Document document = org.springframework.data.elasticsearch.core.document.Document
|
||||
.from(doc);
|
||||
UpdateQuery updateQuery = UpdateQuery.builder("1") //
|
||||
.withDocument(document) //
|
||||
.withIfSeqNo(42) //
|
||||
.withIfPrimaryTerm(13) //
|
||||
.withScript("script")//
|
||||
.withLang("lang") //
|
||||
.withRefreshPolicy(RefreshPolicy.WAIT_UNTIL) //
|
||||
.withRetryOnConflict(7) //
|
||||
.withTimeout("4711s") //
|
||||
.withWaitForActiveShards("all").withFetchSourceIncludes(Collections.singletonList("incl")) //
|
||||
.withFetchSourceExcludes(Collections.singletonList("excl")) //
|
||||
.build();
|
||||
UpdateQuery updateQuery = UpdateQuery.builder("1") //
|
||||
.withDocument(document) //
|
||||
.withIfSeqNo(42) //
|
||||
.withIfPrimaryTerm(13) //
|
||||
.withScript("script")//
|
||||
.withLang("lang") //
|
||||
.withRefreshPolicy(RefreshPolicy.WAIT_UNTIL) //
|
||||
.withRetryOnConflict(7) //
|
||||
.withTimeout("4711s") //
|
||||
.withWaitForActiveShards("all").withFetchSourceIncludes(Collections.singletonList("incl")) //
|
||||
.withFetchSourceExcludes(Collections.singletonList("excl")) //
|
||||
.build();
|
||||
|
||||
UpdateRequestBuilder request = getRequestFactory().updateRequestBuilderFor(client, updateQuery,
|
||||
IndexCoordinates.of("index"));
|
||||
@ -133,7 +131,7 @@ public class ElasticsearchTransportTemplateTests extends ElasticsearchTemplateTe
|
||||
assertThat(request.request().retryOnConflict()).isEqualTo(7);
|
||||
assertThat(request.request().timeout()).isEqualByComparingTo(TimeValue.parseTimeValue("4711s", "test"));
|
||||
assertThat(request.request().waitForActiveShards()).isEqualTo(ActiveShardCount.ALL);
|
||||
FetchSourceContext fetchSourceContext = request.request().fetchSource();
|
||||
FetchSourceContext fetchSourceContext = request.request().fetchSource();
|
||||
assertThat(fetchSourceContext).isNotNull();
|
||||
assertThat(fetchSourceContext.includes()).containsExactlyInAnyOrder("incl");
|
||||
assertThat(fetchSourceContext.excludes()).containsExactlyInAnyOrder("excl");
|
||||
@ -197,11 +195,25 @@ public class ElasticsearchTransportTemplateTests extends ElasticsearchTemplateTe
|
||||
assertThat(request.request().getScript().getType()).isEqualTo(org.elasticsearch.script.ScriptType.STORED);
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-sample-core-transport-template", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
@ -66,7 +61,9 @@ class EntityOperationsTest {
|
||||
@DisplayName("should return routing from DefaultRoutingAccessor")
|
||||
void shouldReturnRoutingFromDefaultRoutingAccessor() {
|
||||
|
||||
EntityWithRouting entity = EntityWithRouting.builder().id("42").routing("theRoute").build();
|
||||
EntityWithRouting entity = new EntityWithRouting();
|
||||
entity.setId("42");
|
||||
entity.setRouting("theRoute");
|
||||
EntityOperations.AdaptibleEntity<EntityWithRouting> adaptibleEntity = entityOperations.forEntity(entity,
|
||||
conversionService, new DefaultRoutingResolver(mappingContext));
|
||||
|
||||
@ -79,8 +76,9 @@ class EntityOperationsTest {
|
||||
@DisplayName("should return routing from JoinField when routing value is null")
|
||||
void shouldReturnRoutingFromJoinFieldWhenRoutingValueIsNull() {
|
||||
|
||||
EntityWithRoutingAndJoinField entity = EntityWithRoutingAndJoinField.builder().id("42")
|
||||
.joinField(new JoinField<>("foo", "foo-routing")).build();
|
||||
EntityWithRoutingAndJoinField entity = new EntityWithRoutingAndJoinField();
|
||||
entity.setId("42");
|
||||
entity.setJoinField(new JoinField<>("foo", "foo-routing"));
|
||||
|
||||
EntityOperations.AdaptibleEntity<EntityWithRoutingAndJoinField> adaptibleEntity = entityOperations.forEntity(entity,
|
||||
conversionService, new DefaultRoutingResolver(mappingContext));
|
||||
@ -93,8 +91,10 @@ class EntityOperationsTest {
|
||||
@Test // #1218
|
||||
@DisplayName("should return routing from routing when JoinField is set")
|
||||
void shouldReturnRoutingFromRoutingWhenJoinFieldIsSet() {
|
||||
EntityWithRoutingAndJoinField entity = EntityWithRoutingAndJoinField.builder().id("42").routing("theRoute")
|
||||
.joinField(new JoinField<>("foo", "foo-routing")).build();
|
||||
EntityWithRoutingAndJoinField entity = new EntityWithRoutingAndJoinField();
|
||||
entity.setId("42");
|
||||
entity.setRouting("theRoute");
|
||||
entity.setJoinField(new JoinField<>("foo", "foo-routing"));
|
||||
|
||||
EntityOperations.AdaptibleEntity<EntityWithRoutingAndJoinField> adaptibleEntity = entityOperations.forEntity(entity,
|
||||
conversionService, new DefaultRoutingResolver(mappingContext));
|
||||
@ -104,26 +104,63 @@ class EntityOperationsTest {
|
||||
assertThat(routing).isEqualTo("theRoute");
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Document(indexName = "entity-operations-test")
|
||||
@Routing("routing")
|
||||
static class EntityWithRouting {
|
||||
@Id private String id;
|
||||
private String routing;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String routing;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getRouting() {
|
||||
return routing;
|
||||
}
|
||||
|
||||
public void setRouting(@Nullable String routing) {
|
||||
this.routing = routing;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Document(indexName = "entity-operations-test")
|
||||
@Routing("routing")
|
||||
static class EntityWithRoutingAndJoinField {
|
||||
@Id private String id;
|
||||
private String routing;
|
||||
private JoinField<String> joinField;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String routing;
|
||||
@Nullable private JoinField<String> joinField;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getRouting() {
|
||||
return routing;
|
||||
}
|
||||
|
||||
public void setRouting(@Nullable String routing) {
|
||||
this.routing = routing;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JoinField<String> getJoinField() {
|
||||
return joinField;
|
||||
}
|
||||
|
||||
public void setJoinField(@Nullable JoinField<String> joinField) {
|
||||
this.joinField = joinField;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,6 @@ package org.springframework.data.elasticsearch.core;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -132,39 +128,103 @@ public class InnerHitsTests {
|
||||
softly.assertAll();
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@Document(indexName = INDEX_NAME)
|
||||
static class City {
|
||||
|
||||
@Id private String name;
|
||||
|
||||
@Nullable @Id private String name;
|
||||
// NOTE: using a custom names here to cover property name matching
|
||||
@Field(name = "hou-ses", type = FieldType.Nested) private Collection<House> houses = new ArrayList<>();
|
||||
@Nullable @Field(name = "hou-ses", type = FieldType.Nested) private Collection<House> houses = new ArrayList<>();
|
||||
|
||||
public City(@Nullable String name, @Nullable Collection<House> houses) {
|
||||
this.name = name;
|
||||
this.houses = houses;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Collection<House> getHouses() {
|
||||
return houses;
|
||||
}
|
||||
|
||||
public void setHouses(@Nullable Collection<House> houses) {
|
||||
this.houses = houses;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
static class House {
|
||||
|
||||
@Field(type = FieldType.Text) private String street;
|
||||
|
||||
@Field(type = FieldType.Text) private String streetNumber;
|
||||
|
||||
@Nullable @Field(type = FieldType.Text) private String street;
|
||||
@Nullable @Field(type = FieldType.Text) private String streetNumber;
|
||||
// NOTE: using a custom names here to cover property name matching
|
||||
@Field(name = "in-habi-tants", type = FieldType.Nested) private List<Inhabitant> inhabitants = new ArrayList<>();
|
||||
@Nullable @Field(name = "in-habi-tants",
|
||||
type = FieldType.Nested) private List<Inhabitant> inhabitants = new ArrayList<>();
|
||||
|
||||
public House(@Nullable String street, @Nullable String streetNumber, @Nullable List<Inhabitant> inhabitants) {
|
||||
this.street = street;
|
||||
this.streetNumber = streetNumber;
|
||||
this.inhabitants = inhabitants;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(@Nullable String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getStreetNumber() {
|
||||
return streetNumber;
|
||||
}
|
||||
|
||||
public void setStreetNumber(@Nullable String streetNumber) {
|
||||
this.streetNumber = streetNumber;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Inhabitant> getInhabitants() {
|
||||
return inhabitants;
|
||||
}
|
||||
|
||||
public void setInhabitants(@Nullable List<Inhabitant> inhabitants) {
|
||||
this.inhabitants = inhabitants;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
static class Inhabitant {
|
||||
// NOTE: using a custom names here to cover property name matching
|
||||
@Nullable @Field(name = "first-name", type = FieldType.Text) private String firstName;
|
||||
@Nullable @Field(name = "last-name", type = FieldType.Text) private String lastName;
|
||||
|
||||
@Field(name = "first-name", type = FieldType.Text) private String firstName;
|
||||
public Inhabitant(@Nullable String firstName, @Nullable String lastName) {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@Field(name = "last-name", type = FieldType.Text) private String lastName;
|
||||
@Nullable
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(@Nullable String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(@Nullable String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
@ -44,6 +42,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -133,21 +132,16 @@ public class LogEntityTests {
|
||||
/**
|
||||
* Simple type to test facets
|
||||
*/
|
||||
@Data
|
||||
@Document(indexName = "test-index-log-core", replicas = 0, refreshInterval = "-1")
|
||||
static class LogEntity {
|
||||
|
||||
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
@Id private String id;
|
||||
|
||||
private String action;
|
||||
|
||||
private long sequenceCode;
|
||||
|
||||
@Field(type = Ip) private String ip;
|
||||
|
||||
@Field(type = Date, format = DateFormat.date_time) private java.util.Date date;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String action;
|
||||
@Nullable private long sequenceCode;
|
||||
@Nullable @Field(type = Ip) private String ip;
|
||||
@Nullable @Field(type = Date, format = DateFormat.date_time) private java.util.Date date;
|
||||
|
||||
private LogEntity() {}
|
||||
|
||||
@ -155,6 +149,49 @@ public class LogEntityTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static SimpleDateFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public long getSequenceCode() {
|
||||
return sequenceCode;
|
||||
}
|
||||
|
||||
public void setSequenceCode(long sequenceCode) {
|
||||
this.sequenceCode = sequenceCode;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public java.util.Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(java.util.Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,9 +18,6 @@ package org.springframework.data.elasticsearch.core;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.get.MultiGetItemResponse;
|
||||
import reactor.core.publisher.Flux;
|
||||
@ -378,13 +375,53 @@ public class ReactiveElasticsearchTemplateCallbackTests {
|
||||
assertThat(saved.get(1).firstname).isEqualTo("before-convert");
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class Person {
|
||||
@Nullable @Id String id;
|
||||
@Nullable String firstname;
|
||||
|
||||
@Id String id;
|
||||
String firstname;
|
||||
public Person() {
|
||||
}
|
||||
|
||||
public Person(@Nullable String id, @Nullable String firstname) {
|
||||
this.id = id;
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(@Nullable String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (id != null ? !id.equals(person.id) : person.id != null) return false;
|
||||
return firstname != null ? firstname.equals(person.firstname) : person.firstname == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (firstname != null ? firstname.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static class ValueCapturingEntityCallback<T> {
|
||||
|
@ -20,11 +20,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@ -81,6 +76,7 @@ import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.*;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@ -179,7 +175,8 @@ public class ReactiveElasticsearchTemplateIntegrationTests {
|
||||
@Test // DATAES-504
|
||||
public void insertWithAutogeneratedIdShouldUpdateEntityId() {
|
||||
|
||||
SampleEntity sampleEntity = SampleEntity.builder().message("wohoo").build();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setMessage("wohoo");
|
||||
|
||||
template.save(sampleEntity) //
|
||||
.map(SampleEntity::getId) //
|
||||
@ -1157,10 +1154,11 @@ public class ReactiveElasticsearchTemplateIntegrationTests {
|
||||
// region Helper functions
|
||||
private SampleEntity randomEntity(String message) {
|
||||
|
||||
return SampleEntity.builder() //
|
||||
.id(UUID.randomUUID().toString()) //
|
||||
.message(StringUtils.hasText(message) ? message : "test message") //
|
||||
.version(System.currentTimeMillis()).build();
|
||||
SampleEntity entity = new SampleEntity();
|
||||
entity.setId(UUID.randomUUID().toString());
|
||||
entity.setMessage(StringUtils.hasText(message) ? message : "test message");
|
||||
entity.setVersion(System.currentTimeMillis());
|
||||
return entity;
|
||||
}
|
||||
|
||||
private IndexQuery getIndexQuery(SampleEntity sampleEntity) {
|
||||
@ -1187,75 +1185,259 @@ public class ReactiveElasticsearchTemplateIntegrationTests {
|
||||
// endregion
|
||||
|
||||
// region Entities
|
||||
@Data
|
||||
@Document(indexName = "marvel")
|
||||
static class Person {
|
||||
|
||||
private @Id String id;
|
||||
private String name;
|
||||
private int age;
|
||||
@Nullable private @Id String id;
|
||||
@Nullable private String name;
|
||||
@Nullable private int age;
|
||||
|
||||
public Person() {}
|
||||
|
||||
public Person(String name, int age) {
|
||||
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class Message {
|
||||
@Nullable String message;
|
||||
|
||||
String message;
|
||||
public Message(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Message message1 = (Message) o;
|
||||
|
||||
return message != null ? message.equals(message1.message) : message1.message == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return message != null ? message.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(exclude = "score")
|
||||
@Document(indexName = DEFAULT_INDEX, replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
private int rate;
|
||||
@Version private Long version;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SampleEntity that = (SampleEntity) o;
|
||||
|
||||
if (rate != that.rate) return false;
|
||||
if (id != null ? !id.equals(that.id) : that.id != null) return false;
|
||||
if (message != null ? !message.equals(that.message) : that.message != null) return false;
|
||||
return version != null ? version.equals(that.version) : that.version == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||
result = 31 * result + rate;
|
||||
result = 31 * result + (version != null ? version.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-reactive-optimistic-entity-template")
|
||||
static class OptimisticEntity {
|
||||
@Id private String id;
|
||||
private String message;
|
||||
private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String message;
|
||||
@Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
|
||||
return seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
|
||||
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-reactive-optimistic-and-versioned-entity-template")
|
||||
static class OptimisticAndVersionedEntity {
|
||||
@Id private String id;
|
||||
private String message;
|
||||
private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Version private Long version;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String message;
|
||||
@Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
|
||||
return seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
|
||||
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-reactive-versioned-entity-template")
|
||||
static class VersionedEntity {
|
||||
@Id private String id;
|
||||
@Version private Long version;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-reactive-information-list", createIndex = false)
|
||||
@Setting(settingPath = "settings/test-settings.json")
|
||||
@Mapping(mappingPath = "mappings/test-mappings.json")
|
||||
private static class EntityWithSettingsAndMappingsReactive {
|
||||
@Id String id;
|
||||
@Nullable @Id String id;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
@ -20,10 +20,6 @@ import static org.elasticsearch.action.search.SearchRequest.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@ -62,6 +58,7 @@ import org.springframework.data.elasticsearch.core.query.Criteria;
|
||||
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.Query;
|
||||
import org.springframework.data.elasticsearch.core.query.StringQuery;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
@ -253,27 +250,89 @@ public class ReactiveElasticsearchTemplateUnitTests {
|
||||
assertThat(captor.getValue().indicesOptions()).isEqualTo(IndicesOptions.LENIENT_EXPAND_OPEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Chris White
|
||||
* @author Sascha Woo
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-sample-core-reactive-template-Unit", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
private int rate;
|
||||
@ScriptedField private Double scriptedRate;
|
||||
private boolean available;
|
||||
private String highlightedMessage;
|
||||
private GeoPoint location;
|
||||
@Version private Long version;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable @ScriptedField private Double scriptedRate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable private String highlightedMessage;
|
||||
@Nullable private GeoPoint location;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public java.lang.Double getScriptedRate() {
|
||||
return scriptedRate;
|
||||
}
|
||||
|
||||
public void setScriptedRate(java.lang.Double scriptedRate) {
|
||||
this.scriptedRate = scriptedRate;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
public String getHighlightedMessage() {
|
||||
return highlightedMessage;
|
||||
}
|
||||
|
||||
public void setHighlightedMessage(String highlightedMessage) {
|
||||
this.highlightedMessage = highlightedMessage;
|
||||
}
|
||||
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(GeoPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ package org.springframework.data.elasticsearch.core;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.skyscreamer.jsonassert.JSONAssert.*;
|
||||
|
||||
import lombok.Data;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@ -506,27 +505,69 @@ public class ReactiveIndexOperationsTest {
|
||||
assertThat(exists).isFalse();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = TESTINDEX, shards = 3, replicas = 2, refreshInterval = "4s")
|
||||
static class Entity {
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Text) private String text;
|
||||
@Field(name = "publication-date", type = FieldType.Date,
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Text) private String text;
|
||||
@Nullable @Field(name = "publication-date", type = FieldType.Date,
|
||||
format = DateFormat.basic_date) private LocalDate publicationDate;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LocalDate getPublicationDate() {
|
||||
return publicationDate;
|
||||
}
|
||||
|
||||
public void setPublicationDate(@Nullable LocalDate publicationDate) {
|
||||
this.publicationDate = publicationDate;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = TESTINDEX, useServerConfiguration = true)
|
||||
static class EntityUseServerConfig {
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = TESTINDEX)
|
||||
@Setting(settingPath = "/settings/test-settings.json")
|
||||
@Mapping(mappingPath = "/mappings/test-mappings.json")
|
||||
static class EntityWithAnnotatedSettingsAndMappings {
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Document(indexName = "test-template", shards = 3, replicas = 2, refreshInterval = "5s")
|
||||
|
@ -20,11 +20,6 @@ import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.skyscreamer.jsonassert.JSONAssert.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@ -460,8 +455,7 @@ class RequestFactoryTests {
|
||||
@DisplayName("should set op_type INDEX if not specified")
|
||||
void shouldSetOpTypeIndexIfNotSpecifiedAndIdIsSet() {
|
||||
|
||||
IndexQuery indexQuery = new IndexQueryBuilder().withId("42").withObject(Person.builder().id("42").lastName("Smith"))
|
||||
.build();
|
||||
IndexQuery indexQuery = new IndexQueryBuilder().withId("42").withObject(new Person("42", "Smith")).build();
|
||||
|
||||
IndexRequest indexRequest = requestFactory.indexRequest(indexQuery, IndexCoordinates.of("optype"));
|
||||
|
||||
@ -473,7 +467,7 @@ class RequestFactoryTests {
|
||||
void shouldSetOpTypeCreateIfSpecified() {
|
||||
|
||||
IndexQuery indexQuery = new IndexQueryBuilder().withOpType(IndexQuery.OpType.CREATE).withId("42")
|
||||
.withObject(Person.builder().id("42").lastName("Smith")).build();
|
||||
.withObject(new Person("42", "Smith")).build();
|
||||
|
||||
IndexRequest indexRequest = requestFactory.indexRequest(indexQuery, IndexCoordinates.of("optype"));
|
||||
|
||||
@ -485,7 +479,7 @@ class RequestFactoryTests {
|
||||
void shouldSetOpTypeIndexIfSpecified() {
|
||||
|
||||
IndexQuery indexQuery = new IndexQueryBuilder().withOpType(IndexQuery.OpType.INDEX).withId("42")
|
||||
.withObject(Person.builder().id("42").lastName("Smith")).build();
|
||||
.withObject(new Person("42", "Smith")).build();
|
||||
|
||||
IndexRequest indexRequest = requestFactory.indexRequest(indexQuery, IndexCoordinates.of("optype"));
|
||||
|
||||
@ -601,14 +595,50 @@ class RequestFactoryTests {
|
||||
assertEquals(expected, searchRequest, false);
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
static class Person {
|
||||
@Nullable @Id String id;
|
||||
@Nullable @Field(name = "last-name") String lastName;
|
||||
@Nullable @Field(name = "current-location") GeoPoint location;
|
||||
|
||||
public Person() {}
|
||||
|
||||
public Person(@Nullable String id, @Nullable String lastName) {
|
||||
this.id = id;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public Person(@Nullable String id, @Nullable String lastName, @Nullable GeoPoint location) {
|
||||
this.id = id;
|
||||
this.lastName = lastName;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(@Nullable String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable GeoPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
|
||||
static class EntityWithSeqNoPrimaryTerm {
|
||||
|
@ -17,12 +17,6 @@ package org.springframework.data.elasticsearch.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -76,10 +70,10 @@ public class SearchAsYouTypeTests {
|
||||
|
||||
private void loadEntities() {
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(SearchAsYouTypeEntity.builder().id("1").name("test 1").suggest("test 1234").build().toIndex());
|
||||
indexQueries.add(SearchAsYouTypeEntity.builder().id("2").name("test 2").suggest("test 5678").build().toIndex());
|
||||
indexQueries.add(SearchAsYouTypeEntity.builder().id("3").name("test 3").suggest("asd 5678").build().toIndex());
|
||||
indexQueries.add(SearchAsYouTypeEntity.builder().id("4").name("test 4").suggest("not match").build().toIndex());
|
||||
indexQueries.add(new SearchAsYouTypeEntity("1", "test 1", "test 1234").toIndex());
|
||||
indexQueries.add(new SearchAsYouTypeEntity("2", "test 2", "test 5678").toIndex());
|
||||
indexQueries.add(new SearchAsYouTypeEntity("3", "test 3", "asd 5678").toIndex());
|
||||
indexQueries.add(new SearchAsYouTypeEntity("4", "test 4", "not match").toIndex());
|
||||
IndexCoordinates index = IndexCoordinates.of("test-index-core-search-as-you-type");
|
||||
operations.bulkIndex(indexQueries, index);
|
||||
operations.indexOps(SearchAsYouTypeEntity.class).refresh();
|
||||
@ -109,9 +103,8 @@ public class SearchAsYouTypeTests {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// then
|
||||
assertThat(result).hasSize(2);
|
||||
assertThat(result).contains(new SearchAsYouTypeEntity("1"));
|
||||
assertThat(result).contains(new SearchAsYouTypeEntity("2"));
|
||||
List<String> ids = result.stream().map(SearchAsYouTypeEntity::getId).collect(Collectors.toList());
|
||||
assertThat(ids).containsExactlyInAnyOrder("1", "2");
|
||||
}
|
||||
|
||||
@Test // DATAES-773
|
||||
@ -131,9 +124,8 @@ public class SearchAsYouTypeTests {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// then
|
||||
assertThat(result).hasSize(2);
|
||||
assertThat(result).contains(new SearchAsYouTypeEntity("2"));
|
||||
assertThat(result).contains(new SearchAsYouTypeEntity("3"));
|
||||
List<String> ids = result.stream().map(SearchAsYouTypeEntity::getId).collect(Collectors.toList());
|
||||
assertThat(ids).containsExactlyInAnyOrder("2", "3");
|
||||
}
|
||||
|
||||
@Test // DATAES-773
|
||||
@ -153,18 +145,12 @@ public class SearchAsYouTypeTests {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// then
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result).contains(new SearchAsYouTypeEntity("4"));
|
||||
assertThat(result.get(0).getId()).isEqualTo("4");
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Aleksei Arsenev
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
|
||||
@Document(indexName = "test-index-core-search-as-you-type", replicas = 0, refreshInterval = "-1")
|
||||
static class SearchAsYouTypeEntity {
|
||||
|
||||
@ -172,17 +158,71 @@ public class SearchAsYouTypeTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@NonNull @Id @EqualsAndHashCode.Include private String id;
|
||||
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
@Nullable @Field(type = FieldType.Search_As_You_Type, maxShingleSize = 4) private String suggest;
|
||||
|
||||
public SearchAsYouTypeEntity() {
|
||||
}
|
||||
|
||||
public SearchAsYouTypeEntity(String id, @Nullable String name, @Nullable String suggest) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.suggest = suggest;
|
||||
}
|
||||
|
||||
public IndexQuery toIndex() {
|
||||
IndexQuery indexQuery = new IndexQuery();
|
||||
indexQuery.setId(getId());
|
||||
indexQuery.setObject(this);
|
||||
return indexQuery;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSuggest() {
|
||||
return suggest;
|
||||
}
|
||||
|
||||
public void setSuggest(@Nullable String suggest) {
|
||||
this.suggest = suggest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SearchAsYouTypeEntity that = (SearchAsYouTypeEntity) o;
|
||||
|
||||
if (id != null ? !id.equals(that.id) : that.id != null) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
return suggest != null ? suggest.equals(that.suggest) : that.suggest == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
result = 31 * result + (suggest != null ? suggest.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -39,6 +34,7 @@ import org.springframework.data.elasticsearch.core.query.Query;
|
||||
import org.springframework.data.elasticsearch.core.query.SourceFilter;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -57,7 +53,12 @@ public class SourceFilterIntegrationTests {
|
||||
indexOps.create();
|
||||
indexOps.putMapping();
|
||||
|
||||
operations.save(Entity.builder().id("42").field1("one").field2("two").field3("three").build());
|
||||
Entity entity = new Entity();
|
||||
entity.setId("42");
|
||||
entity.setField1("one");
|
||||
entity.setField2("two");
|
||||
entity.setField3("three");
|
||||
operations.save(entity);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@ -201,15 +202,47 @@ public class SourceFilterIntegrationTests {
|
||||
assertThat(entity.getField3()).isNull();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Document(indexName = "sourcefilter-tests")
|
||||
public static class Entity {
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Text) private String field1;
|
||||
@Field(type = FieldType.Text) private String field2;
|
||||
@Field(type = FieldType.Text) private String field3;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Text) private String field1;
|
||||
@Nullable @Field(type = FieldType.Text) private String field2;
|
||||
@Nullable @Field(type = FieldType.Text) private String field3;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getField1() {
|
||||
return field1;
|
||||
}
|
||||
|
||||
public void setField1(@Nullable String field1) {
|
||||
this.field1 = field1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getField2() {
|
||||
return field2;
|
||||
}
|
||||
|
||||
public void setField2(@Nullable String field2) {
|
||||
this.field2 = field2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getField3() {
|
||||
return field3;
|
||||
}
|
||||
|
||||
public void setField3(@Nullable String field3) {
|
||||
this.field3 = field3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.Integer;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.lang.Integer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -50,6 +48,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -131,33 +130,79 @@ public class ElasticsearchTemplateAggregationTests {
|
||||
assertThat(searchHits.hasSearchHits()).isFalse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple type to test facets
|
||||
*
|
||||
* @author Artur Konczak
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
@Data
|
||||
@Document(indexName = "test-index-articles-core-aggregation", replicas = 0, refreshInterval = "-1")
|
||||
static class ArticleEntity {
|
||||
|
||||
@Id private String id;
|
||||
private String title;
|
||||
@Field(type = Text, fielddata = true) private String subject;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String title;
|
||||
@Nullable @Field(type = Text, fielddata = true) private String subject;
|
||||
|
||||
@MultiField(mainField = @Field(type = Text),
|
||||
@Nullable @MultiField(mainField = @Field(type = Text),
|
||||
otherFields = {
|
||||
@InnerField(suffix = "untouched", type = Text, store = true, fielddata = true, analyzer = "keyword"),
|
||||
@InnerField(suffix = "sort", type = Text, store = true,
|
||||
analyzer = "keyword") }) private List<String> authors = new ArrayList<>();
|
||||
|
||||
@Field(type = Integer, store = true) private List<Integer> publishedYears = new ArrayList<>();
|
||||
@Nullable @Field(type = Integer, store = true) private List<Integer> publishedYears = new ArrayList<>();
|
||||
|
||||
private int score;
|
||||
@Nullable private int score;
|
||||
|
||||
public ArticleEntity(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(@Nullable String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(@Nullable String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void setAuthors(@Nullable List<String> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<java.lang.Integer> getPublishedYears() {
|
||||
return publishedYears;
|
||||
}
|
||||
|
||||
public void setPublishedYears(@Nullable List<java.lang.Integer> publishedYears) {
|
||||
this.publishedYears = publishedYears;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(int score) {
|
||||
this.score = score;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,8 +18,6 @@ package org.springframework.data.elasticsearch.core.event;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -216,20 +214,56 @@ abstract class ElasticsearchOperationsCallbackIntegrationTest {
|
||||
assertThat(capturedIndexQuery.getPrimaryTerm()).isEqualTo(seqNoPrimaryTerm.getPrimaryTerm());
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = INDEX)
|
||||
static class SampleEntity {
|
||||
@Id private String id;
|
||||
private String text;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String text;
|
||||
|
||||
@JoinTypeRelations(relations = { @JoinTypeRelation(parent = "question",
|
||||
children = { "answer" }) }) @Nullable private JoinField<String> joinField;
|
||||
@Nullable @JoinTypeRelations(relations = { @JoinTypeRelation(parent = "question",
|
||||
children = { "answer" }) })
|
||||
private JoinField<String> joinField;
|
||||
|
||||
private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
|
||||
public SampleEntity(String id, String text) {
|
||||
this.id = id;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JoinField<String> getJoinField() {
|
||||
return joinField;
|
||||
}
|
||||
|
||||
public void setJoinField(@Nullable JoinField<String> joinField) {
|
||||
this.joinField = joinField;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
|
||||
return seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
|
||||
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,6 @@ package org.springframework.data.elasticsearch.core.geo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -50,6 +43,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTem
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -106,23 +100,24 @@ public class ElasticsearchTemplateGeoTests {
|
||||
String latLonString = "51.000000, 0.100000";
|
||||
String geohash = "u10j46mkfekr";
|
||||
Geohash.stringEncode(0.100000, 51.000000);
|
||||
LocationMarkerEntity location1 = LocationMarkerEntity.builder() //
|
||||
.id("1").name("Artur Konczak") //
|
||||
.locationAsString(latLonString) //
|
||||
.locationAsArray(lonLatArray) //
|
||||
.locationAsGeoHash(geohash).build();
|
||||
LocationMarkerEntity location2 = LocationMarkerEntity.builder() //
|
||||
.id("2").name("Mohsin Husen") //
|
||||
.locationAsString(geohash.substring(0, 8)) //
|
||||
.locationAsArray(lonLatArray) //
|
||||
.locationAsGeoHash(geohash.substring(0, 8)) //
|
||||
.build();
|
||||
LocationMarkerEntity location3 = LocationMarkerEntity.builder() //
|
||||
.id("3").name("Rizwan Idrees") //
|
||||
.locationAsString(geohash) //
|
||||
.locationAsArray(lonLatArray) //
|
||||
.locationAsGeoHash(geohash) //
|
||||
.build();
|
||||
LocationMarkerEntity location1 = new LocationMarkerEntity();
|
||||
location1.setId("1");
|
||||
location1.setName("Artur Konczak");
|
||||
location1.setLocationAsString(latLonString);
|
||||
location1.setLocationAsArray(lonLatArray);
|
||||
location1.setLocationAsGeoHash(geohash);
|
||||
LocationMarkerEntity location2 = new LocationMarkerEntity();
|
||||
location2.setId("2");
|
||||
location2.setName("Mohsin Husen");
|
||||
location2.setLocationAsString(geohash.substring(0, 8));
|
||||
location2.setLocationAsArray(lonLatArray);
|
||||
location2.setLocationAsGeoHash(geohash.substring(0, 8));
|
||||
LocationMarkerEntity location3 = new LocationMarkerEntity();
|
||||
location3.setId("3");
|
||||
location3.setName("Rizwan Idrees");
|
||||
location3.setLocationAsString(geohash);
|
||||
location3.setLocationAsArray(lonLatArray);
|
||||
location3.setLocationAsGeoHash(geohash);
|
||||
indexQueries.add(buildIndex(location1));
|
||||
indexQueries.add(buildIndex(location2));
|
||||
indexQueries.add(buildIndex(location3));
|
||||
@ -366,20 +361,44 @@ public class ElasticsearchTemplateGeoTests {
|
||||
* @author Franck Marchand
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
@Data
|
||||
@Document(indexName = "test-index-author-marker-core-geo", replicas = 0, refreshInterval = "-1")
|
||||
static class AuthorMarkerEntity {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
|
||||
private GeoPoint location;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable private GeoPoint location;
|
||||
|
||||
private AuthorMarkerEntity() {}
|
||||
|
||||
public AuthorMarkerEntity(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable GeoPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -417,25 +436,52 @@ public class ElasticsearchTemplateGeoTests {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Franck Marchand
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-location-marker-core-geo", replicas = 0, refreshInterval = "-1")
|
||||
static class LocationMarkerEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @GeoPointField private String locationAsString;
|
||||
@Nullable @GeoPointField private double[] locationAsArray;
|
||||
@Nullable @GeoPointField private String locationAsGeoHash;
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@GeoPointField private String locationAsString;
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@GeoPointField private double[] locationAsArray;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@GeoPointField private String locationAsGeoHash;
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocationAsString() {
|
||||
return locationAsString;
|
||||
}
|
||||
|
||||
public void setLocationAsString(String locationAsString) {
|
||||
this.locationAsString = locationAsString;
|
||||
}
|
||||
|
||||
public double[] getLocationAsArray() {
|
||||
return locationAsArray;
|
||||
}
|
||||
|
||||
public void setLocationAsArray(double[] locationAsArray) {
|
||||
this.locationAsArray = locationAsArray;
|
||||
}
|
||||
|
||||
public String getLocationAsGeoHash() {
|
||||
return locationAsGeoHash;
|
||||
}
|
||||
|
||||
public void setLocationAsGeoHash(String locationAsGeoHash) {
|
||||
this.locationAsGeoHash = locationAsGeoHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,33 +15,254 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.geo;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* this class contains each GeoJson type as explicit type and as GeoJson interface. Used by several test classes
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Document(indexName = "geojson-index")
|
||||
public class GeoJsonEntity {
|
||||
@Id private String id;
|
||||
GeoJsonPoint point1;
|
||||
GeoJson<? extends Iterable<?>> point2;
|
||||
GeoJsonMultiPoint multiPoint1;
|
||||
GeoJson<Iterable<Point>> multiPoint2;
|
||||
GeoJsonLineString lineString1;
|
||||
GeoJson<Iterable<Point>> lineString2;
|
||||
GeoJsonMultiLineString multiLineString1;
|
||||
GeoJson<Iterable<GeoJsonLineString>> multiLineString2;
|
||||
GeoJsonPolygon polygon1;
|
||||
GeoJson<Iterable<GeoJsonLineString>> polygon2;
|
||||
GeoJsonMultiPolygon multiPolygon1;
|
||||
GeoJson<Iterable<GeoJsonPolygon>> multiPolygon2;
|
||||
GeoJsonGeometryCollection geometryCollection1;
|
||||
GeoJson<Iterable<GeoJson<?>>> geometryCollection2;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private GeoJsonPoint point1;
|
||||
@Nullable private GeoJson<? extends Iterable<?>> point2;
|
||||
@Nullable private GeoJsonMultiPoint multiPoint1;
|
||||
@Nullable private GeoJson<Iterable<Point>> multiPoint2;
|
||||
@Nullable private GeoJsonLineString lineString1;
|
||||
@Nullable private GeoJson<Iterable<Point>> lineString2;
|
||||
@Nullable private GeoJsonMultiLineString multiLineString1;
|
||||
@Nullable private GeoJson<Iterable<GeoJsonLineString>> multiLineString2;
|
||||
@Nullable private GeoJsonPolygon polygon1;
|
||||
@Nullable private GeoJson<Iterable<GeoJsonLineString>> polygon2;
|
||||
@Nullable private GeoJsonMultiPolygon multiPolygon1;
|
||||
@Nullable private GeoJson<Iterable<GeoJsonPolygon>> multiPolygon2;
|
||||
@Nullable private GeoJsonGeometryCollection geometryCollection1;
|
||||
@Nullable private GeoJson<Iterable<GeoJson<?>>> geometryCollection2;
|
||||
|
||||
public GeoJsonEntity() {}
|
||||
|
||||
public GeoJsonEntity(@Nullable String id, @Nullable GeoJsonPoint point1,
|
||||
@Nullable GeoJson<? extends Iterable<?>> point2, @Nullable GeoJsonMultiPoint multiPoint1,
|
||||
@Nullable GeoJson<Iterable<Point>> multiPoint2, @Nullable GeoJsonLineString lineString1,
|
||||
@Nullable GeoJson<Iterable<Point>> lineString2, @Nullable GeoJsonMultiLineString multiLineString1,
|
||||
@Nullable GeoJson<Iterable<GeoJsonLineString>> multiLineString2, @Nullable GeoJsonPolygon polygon1,
|
||||
@Nullable GeoJson<Iterable<GeoJsonLineString>> polygon2, @Nullable GeoJsonMultiPolygon multiPolygon1,
|
||||
@Nullable GeoJson<Iterable<GeoJsonPolygon>> multiPolygon2,
|
||||
@Nullable GeoJsonGeometryCollection geometryCollection1,
|
||||
@Nullable GeoJson<Iterable<GeoJson<?>>> geometryCollection2) {
|
||||
this.id = id;
|
||||
this.point1 = point1;
|
||||
this.point2 = point2;
|
||||
this.multiPoint1 = multiPoint1;
|
||||
this.multiPoint2 = multiPoint2;
|
||||
this.lineString1 = lineString1;
|
||||
this.lineString2 = lineString2;
|
||||
this.multiLineString1 = multiLineString1;
|
||||
this.multiLineString2 = multiLineString2;
|
||||
this.polygon1 = polygon1;
|
||||
this.polygon2 = polygon2;
|
||||
this.multiPolygon1 = multiPolygon1;
|
||||
this.multiPolygon2 = multiPolygon2;
|
||||
this.geometryCollection1 = geometryCollection1;
|
||||
this.geometryCollection2 = geometryCollection2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJsonPoint getPoint1() {
|
||||
return point1;
|
||||
}
|
||||
|
||||
public void setPoint1(@Nullable GeoJsonPoint point1) {
|
||||
this.point1 = point1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJson<? extends Iterable<?>> getPoint2() {
|
||||
return point2;
|
||||
}
|
||||
|
||||
public void setPoint2(@Nullable GeoJson<? extends Iterable<?>> point2) {
|
||||
this.point2 = point2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJsonMultiPoint getMultiPoint1() {
|
||||
return multiPoint1;
|
||||
}
|
||||
|
||||
public void setMultiPoint1(@Nullable GeoJsonMultiPoint multiPoint1) {
|
||||
this.multiPoint1 = multiPoint1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJson<Iterable<Point>> getMultiPoint2() {
|
||||
return multiPoint2;
|
||||
}
|
||||
|
||||
public void setMultiPoint2(@Nullable GeoJson<Iterable<Point>> multiPoint2) {
|
||||
this.multiPoint2 = multiPoint2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJsonLineString getLineString1() {
|
||||
return lineString1;
|
||||
}
|
||||
|
||||
public void setLineString1(@Nullable GeoJsonLineString lineString1) {
|
||||
this.lineString1 = lineString1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJson<Iterable<Point>> getLineString2() {
|
||||
return lineString2;
|
||||
}
|
||||
|
||||
public void setLineString2(@Nullable GeoJson<Iterable<Point>> lineString2) {
|
||||
this.lineString2 = lineString2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJsonMultiLineString getMultiLineString1() {
|
||||
return multiLineString1;
|
||||
}
|
||||
|
||||
public void setMultiLineString1(@Nullable GeoJsonMultiLineString multiLineString1) {
|
||||
this.multiLineString1 = multiLineString1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJson<Iterable<GeoJsonLineString>> getMultiLineString2() {
|
||||
return multiLineString2;
|
||||
}
|
||||
|
||||
public void setMultiLineString2(@Nullable GeoJson<Iterable<GeoJsonLineString>> multiLineString2) {
|
||||
this.multiLineString2 = multiLineString2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJsonPolygon getPolygon1() {
|
||||
return polygon1;
|
||||
}
|
||||
|
||||
public void setPolygon1(@Nullable GeoJsonPolygon polygon1) {
|
||||
this.polygon1 = polygon1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJson<Iterable<GeoJsonLineString>> getPolygon2() {
|
||||
return polygon2;
|
||||
}
|
||||
|
||||
public void setPolygon2(@Nullable GeoJson<Iterable<GeoJsonLineString>> polygon2) {
|
||||
this.polygon2 = polygon2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJsonMultiPolygon getMultiPolygon1() {
|
||||
return multiPolygon1;
|
||||
}
|
||||
|
||||
public void setMultiPolygon1(@Nullable GeoJsonMultiPolygon multiPolygon1) {
|
||||
this.multiPolygon1 = multiPolygon1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJson<Iterable<GeoJsonPolygon>> getMultiPolygon2() {
|
||||
return multiPolygon2;
|
||||
}
|
||||
|
||||
public void setMultiPolygon2(@Nullable GeoJson<Iterable<GeoJsonPolygon>> multiPolygon2) {
|
||||
this.multiPolygon2 = multiPolygon2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJsonGeometryCollection getGeometryCollection1() {
|
||||
return geometryCollection1;
|
||||
}
|
||||
|
||||
public void setGeometryCollection1(@Nullable GeoJsonGeometryCollection geometryCollection1) {
|
||||
this.geometryCollection1 = geometryCollection1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJson<Iterable<GeoJson<?>>> getGeometryCollection2() {
|
||||
return geometryCollection2;
|
||||
}
|
||||
|
||||
public void setGeometryCollection2(@Nullable GeoJson<Iterable<GeoJson<?>>> geometryCollection2) {
|
||||
this.geometryCollection2 = geometryCollection2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof GeoJsonEntity))
|
||||
return false;
|
||||
|
||||
GeoJsonEntity that = (GeoJsonEntity) o;
|
||||
|
||||
if (id != null ? !id.equals(that.id) : that.id != null)
|
||||
return false;
|
||||
if (point1 != null ? !point1.equals(that.point1) : that.point1 != null)
|
||||
return false;
|
||||
if (point2 != null ? !point2.equals(that.point2) : that.point2 != null)
|
||||
return false;
|
||||
if (multiPoint1 != null ? !multiPoint1.equals(that.multiPoint1) : that.multiPoint1 != null)
|
||||
return false;
|
||||
if (multiPoint2 != null ? !multiPoint2.equals(that.multiPoint2) : that.multiPoint2 != null)
|
||||
return false;
|
||||
if (lineString1 != null ? !lineString1.equals(that.lineString1) : that.lineString1 != null)
|
||||
return false;
|
||||
if (lineString2 != null ? !lineString2.equals(that.lineString2) : that.lineString2 != null)
|
||||
return false;
|
||||
if (multiLineString1 != null ? !multiLineString1.equals(that.multiLineString1) : that.multiLineString1 != null)
|
||||
return false;
|
||||
if (multiLineString2 != null ? !multiLineString2.equals(that.multiLineString2) : that.multiLineString2 != null)
|
||||
return false;
|
||||
if (polygon1 != null ? !polygon1.equals(that.polygon1) : that.polygon1 != null)
|
||||
return false;
|
||||
if (polygon2 != null ? !polygon2.equals(that.polygon2) : that.polygon2 != null)
|
||||
return false;
|
||||
if (multiPolygon1 != null ? !multiPolygon1.equals(that.multiPolygon1) : that.multiPolygon1 != null)
|
||||
return false;
|
||||
if (multiPolygon2 != null ? !multiPolygon2.equals(that.multiPolygon2) : that.multiPolygon2 != null)
|
||||
return false;
|
||||
if (geometryCollection1 != null ? !geometryCollection1.equals(that.geometryCollection1)
|
||||
: that.geometryCollection1 != null)
|
||||
return false;
|
||||
return geometryCollection2 != null ? geometryCollection2.equals(that.geometryCollection2)
|
||||
: that.geometryCollection2 == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (point1 != null ? point1.hashCode() : 0);
|
||||
result = 31 * result + (point2 != null ? point2.hashCode() : 0);
|
||||
result = 31 * result + (multiPoint1 != null ? multiPoint1.hashCode() : 0);
|
||||
result = 31 * result + (multiPoint2 != null ? multiPoint2.hashCode() : 0);
|
||||
result = 31 * result + (lineString1 != null ? lineString1.hashCode() : 0);
|
||||
result = 31 * result + (lineString2 != null ? lineString2.hashCode() : 0);
|
||||
result = 31 * result + (multiLineString1 != null ? multiLineString1.hashCode() : 0);
|
||||
result = 31 * result + (multiLineString2 != null ? multiLineString2.hashCode() : 0);
|
||||
result = 31 * result + (polygon1 != null ? polygon1.hashCode() : 0);
|
||||
result = 31 * result + (polygon2 != null ? polygon2.hashCode() : 0);
|
||||
result = 31 * result + (multiPolygon1 != null ? multiPolygon1.hashCode() : 0);
|
||||
result = 31 * result + (multiPolygon2 != null ? multiPolygon2.hashCode() : 0);
|
||||
result = 31 * result + (geometryCollection1 != null ? geometryCollection1.hashCode() : 0);
|
||||
result = 31 * result + (geometryCollection2 != null ? geometryCollection2.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,6 @@ package org.springframework.data.elasticsearch.core.geo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@ -38,6 +35,7 @@ import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -60,7 +58,7 @@ class GeoJsonIntegrationTest {
|
||||
new Point(20, 20), //
|
||||
new Point(10, 20), //
|
||||
new Point(10, 10));
|
||||
private final Area area10To20 = Area.builder().id("area10To20").area(geoShape10To20) /**/.build();
|
||||
private final Area area10To20 = new Area("area10To20", geoShape10To20);
|
||||
|
||||
private final GeoJsonPolygon geoShape5To35 = GeoJsonPolygon.of( //
|
||||
new Point(5, 5), //
|
||||
@ -68,7 +66,7 @@ class GeoJsonIntegrationTest {
|
||||
new Point(35, 35), //
|
||||
new Point(5, 35), //
|
||||
new Point(5, 5));
|
||||
private final Area area5To35 = Area.builder().id("area5To35").area(geoShape5To35).build();
|
||||
private final Area area5To35 = new Area("area5To35", geoShape5To35);
|
||||
|
||||
private final GeoJsonPolygon geoShape15To25 = GeoJsonPolygon.of( //
|
||||
new Point(15, 15), //
|
||||
@ -76,7 +74,7 @@ class GeoJsonIntegrationTest {
|
||||
new Point(25, 25), //
|
||||
new Point(15, 25), //
|
||||
new Point(15, 15));
|
||||
private final Area area15To25 = Area.builder().id("area15To25").area(geoShape15To25).build();
|
||||
private final Area area15To25 = new Area("area15To25", geoShape15To25);
|
||||
|
||||
private final GeoJsonPolygon geoShape30To40 = GeoJsonPolygon.of( //
|
||||
new Point(30, 30), //
|
||||
@ -84,7 +82,7 @@ class GeoJsonIntegrationTest {
|
||||
new Point(40, 40), //
|
||||
new Point(30, 40), //
|
||||
new Point(30, 30));
|
||||
private final Area area30To40 = Area.builder().id("area30To40").area(geoShape30To40).build();
|
||||
private final Area area30To40 = new Area("area30To40",geoShape30To40);
|
||||
|
||||
private final GeoJsonPolygon geoShape32To37 = GeoJsonPolygon.of( //
|
||||
new Point(32, 32), //
|
||||
@ -92,7 +90,7 @@ class GeoJsonIntegrationTest {
|
||||
new Point(37, 37), //
|
||||
new Point(32, 37), //
|
||||
new Point(32, 32));
|
||||
private final Area area32To37 = Area.builder().id("area32To37").area(geoShape30To40).build();
|
||||
private final Area area32To37 = new Area("area32To37",geoShape30To40);
|
||||
// endregion
|
||||
|
||||
// region setup
|
||||
@ -137,23 +135,22 @@ class GeoJsonIntegrationTest {
|
||||
.of(Arrays.asList(GeoJsonPoint.of(12, 34), GeoJsonPolygon
|
||||
.of(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12), new Point(12, 34)))));
|
||||
|
||||
GeoJsonEntity entity = GeoJsonEntity.builder() //
|
||||
.id("42") //
|
||||
.point1(GeoJsonPoint.of(12, 34)) //
|
||||
.point2(GeoJsonPoint.of(56, 78)) //
|
||||
.multiPoint1(GeoJsonMultiPoint.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))) //
|
||||
.multiPoint2(GeoJsonMultiPoint.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))) //
|
||||
.lineString1(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))) //
|
||||
.lineString2(GeoJsonLineString.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))) //
|
||||
.multiLineString1(multiLineString) //
|
||||
.multiLineString2(multiLineString) //
|
||||
.polygon1(geoJsonPolygon) //
|
||||
.polygon2(geoJsonPolygon) //
|
||||
.multiPolygon1(geoJsonMultiPolygon) //
|
||||
.multiPolygon2(geoJsonMultiPolygon) //
|
||||
.geometryCollection1(geoJsonGeometryCollection) //
|
||||
.geometryCollection2(geoJsonGeometryCollection) //
|
||||
.build(); //
|
||||
GeoJsonEntity entity = new GeoJsonEntity();
|
||||
entity.setId("42");
|
||||
entity.setPoint1(GeoJsonPoint.of(12, 34));
|
||||
entity.setPoint2(GeoJsonPoint.of(56, 78));
|
||||
entity.setMultiPoint1(GeoJsonMultiPoint.of(new Point(12, 34), new Point(56, 78), new Point(90, 12)));
|
||||
entity.setMultiPoint2(GeoJsonMultiPoint.of(new Point(90, 12), new Point(56, 78), new Point(12, 34)));
|
||||
entity.setLineString1(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12)));
|
||||
entity.setLineString2(GeoJsonLineString.of(new Point(90, 12), new Point(56, 78), new Point(12, 34)));
|
||||
entity.setMultiLineString1(multiLineString);
|
||||
entity.setMultiLineString2(multiLineString);
|
||||
entity.setPolygon1(geoJsonPolygon);
|
||||
entity.setPolygon2(geoJsonPolygon);
|
||||
entity.setMultiPolygon1(geoJsonMultiPolygon);
|
||||
entity.setMultiPolygon2(geoJsonMultiPolygon);
|
||||
entity.setGeometryCollection1(geoJsonGeometryCollection);
|
||||
entity.setGeometryCollection2(geoJsonGeometryCollection);
|
||||
|
||||
operations.save(entity);
|
||||
indexOps.refresh();
|
||||
@ -209,12 +206,33 @@ class GeoJsonIntegrationTest {
|
||||
// endregion
|
||||
|
||||
// region test classes
|
||||
@Data
|
||||
@Builder
|
||||
@Document(indexName = "areas")
|
||||
static class Area {
|
||||
@Id private String id;
|
||||
@Field(name = "the_area") private GeoJsonPolygon area;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(name = "the_area") private GeoJsonPolygon area;
|
||||
|
||||
public Area(@Nullable String id, @Nullable GeoJsonPolygon area) {
|
||||
this.id = id;
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJsonPolygon getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public void setArea(@Nullable GeoJsonPolygon area) {
|
||||
this.area = area;
|
||||
}
|
||||
}
|
||||
// endregion
|
||||
|
||||
|
@ -17,8 +17,6 @@ package org.springframework.data.elasticsearch.core.index;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -36,6 +34,7 @@ import org.springframework.data.elasticsearch.core.IndexInformation;
|
||||
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.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -98,11 +97,19 @@ public class IndexOperationIntegrationTests {
|
||||
JSONAssert.assertEquals(expectedMappings, indexInformation.getMapping().toJson(), false);
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = INDEX_NAME)
|
||||
@Setting(settingPath = "settings/test-settings.json")
|
||||
@Mapping(mappingPath = "mappings/test-mappings.json")
|
||||
protected static class EntityWithSettingsAndMappings {
|
||||
@Id String id;
|
||||
@Nullable private @Id String id;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.Object;
|
||||
import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.lang.Integer;
|
||||
import java.lang.Object;
|
||||
import java.math.BigDecimal;
|
||||
@ -128,11 +121,11 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
String id = "abc";
|
||||
|
||||
IndexCoordinates index = IndexCoordinates.of("test-index-stock-mapping-builder");
|
||||
operations.index(buildIndex(StockPrice.builder() //
|
||||
.id(id) //
|
||||
.symbol(symbol) //
|
||||
.price(BigDecimal.valueOf(price)) //
|
||||
.build()), index);
|
||||
StockPrice stockPrice = new StockPrice(); //
|
||||
stockPrice.setId(id);
|
||||
stockPrice.setSymbol(symbol);
|
||||
stockPrice.setPrice(BigDecimal.valueOf(price));
|
||||
operations.index(buildIndex(stockPrice), index);
|
||||
operations.indexOps(StockPrice.class).refresh();
|
||||
|
||||
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
|
||||
@ -303,17 +296,28 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
indexOps.delete();
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "ignore-above-index")
|
||||
static class IgnoreAboveEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Keyword, ignoreAbove = 10) private String message;
|
||||
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Keyword, ignoreAbove = 10) private String message;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
static class FieldNameEntity {
|
||||
@ -380,64 +384,165 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||
searchAnalyzer = "standard") }) private String description;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(@Nullable Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<java.lang.Integer, Collection<String>> getBuckets() {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
public void setBuckets(@Nullable Map<java.lang.Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-simple-recursive-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class SimpleRecursiveEntity {
|
||||
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Object,
|
||||
ignoreFields = { "circularObject" }) private SimpleRecursiveEntity circularObject;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SimpleRecursiveEntity getCircularObject() {
|
||||
return circularObject;
|
||||
}
|
||||
|
||||
public void setCircularObject(@Nullable SimpleRecursiveEntity circularObject) {
|
||||
this.circularObject = circularObject;
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-copy-to-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class CopyToEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String firstName;
|
||||
@Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String lastName;
|
||||
@Nullable @Field(type = FieldType.Keyword) private String name;
|
||||
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Keyword, copyTo = "name") private String firstName;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Keyword, copyTo = "name") private String lastName;
|
||||
@Nullable
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Keyword) private String name;
|
||||
public void setFirstName(@Nullable String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(@Nullable String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-normalizer-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
@Setting(settingPath = "/settings/test-normalizer.json")
|
||||
static class NormalizerEntity {
|
||||
|
||||
@Id private String id;
|
||||
|
||||
@Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name;
|
||||
|
||||
@MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case",
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name;
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case",
|
||||
type = FieldType.Keyword, normalizer = "lower_case_normalizer") }) private String description;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
static class Author {
|
||||
@ -510,71 +615,163 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-stock-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class StockPrice {
|
||||
|
||||
@Id private String id;
|
||||
|
||||
private String symbol;
|
||||
|
||||
@Field(type = FieldType.Double) private BigDecimal price;
|
||||
}
|
||||
|
||||
static class AbstractInheritedEntity {
|
||||
|
||||
@Nullable @Id private String id;
|
||||
|
||||
@Nullable @Field(type = FieldType.Date, format = DateFormat.date_time, index = false) private Date createdDate;
|
||||
@Nullable private String symbol;
|
||||
@Nullable @Field(type = FieldType.Double) private BigDecimal price;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getCreatedDate() {
|
||||
return createdDate;
|
||||
public String getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public void setSymbol(@Nullable String symbol) {
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(@Nullable BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
}
|
||||
|
||||
static class AbstractInheritedEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Date, format = DateFormat.date_time, index = false) private Date createdDate;
|
||||
@Nullable public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@Nullable public Date getCreatedDate() {
|
||||
return createdDate;
|
||||
}
|
||||
public void setCreatedDate(Date createdDate) {
|
||||
this.createdDate = createdDate;
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-geo-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class GeoEntity {
|
||||
|
||||
@Id private String id;
|
||||
|
||||
// geo shape - Spring Data
|
||||
private Box box;
|
||||
private Circle circle;
|
||||
private Polygon polygon;
|
||||
|
||||
// geo point - Custom implementation + Spring Data
|
||||
@GeoPointField private Point pointA;
|
||||
private GeoPoint pointB;
|
||||
@GeoPointField private String pointC;
|
||||
@GeoPointField private double[] pointD;
|
||||
|
||||
// geo shape, until e have the classes for this, us a strng
|
||||
@GeoShapeField private String shape1;
|
||||
@GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false,
|
||||
@Nullable @Id private String id;
|
||||
// geo shape - Spring Data
|
||||
@Nullable private Box box;
|
||||
@Nullable private Circle circle;
|
||||
@Nullable private Polygon polygon;
|
||||
// geo point - Custom implementation + Spring Data
|
||||
@Nullable @GeoPointField private Point pointA;
|
||||
@Nullable private GeoPoint pointB;
|
||||
@Nullable @GeoPointField private String pointC;
|
||||
@Nullable @GeoPointField private double[] pointD;
|
||||
// geo shape, until e have the classes for this, us a strng
|
||||
@Nullable @GeoShapeField private String shape1;
|
||||
@Nullable @GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false,
|
||||
orientation = GeoShapeField.Orientation.clockwise) private String shape2;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Box getBox() {
|
||||
return box;
|
||||
}
|
||||
|
||||
public void setBox(@Nullable Box box) {
|
||||
this.box = box;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Circle getCircle() {
|
||||
return circle;
|
||||
}
|
||||
|
||||
public void setCircle(@Nullable Circle circle) {
|
||||
this.circle = circle;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Polygon getPolygon() {
|
||||
return polygon;
|
||||
}
|
||||
|
||||
public void setPolygon(@Nullable Polygon polygon) {
|
||||
this.polygon = polygon;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Point getPointA() {
|
||||
return pointA;
|
||||
}
|
||||
|
||||
public void setPointA(@Nullable Point pointA) {
|
||||
this.pointA = pointA;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getPointB() {
|
||||
return pointB;
|
||||
}
|
||||
|
||||
public void setPointB(@Nullable GeoPoint pointB) {
|
||||
this.pointB = pointB;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPointC() {
|
||||
return pointC;
|
||||
}
|
||||
|
||||
public void setPointC(@Nullable String pointC) {
|
||||
this.pointC = pointC;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public double[] getPointD() {
|
||||
return pointD;
|
||||
}
|
||||
|
||||
public void setPointD(@Nullable double[] pointD) {
|
||||
this.pointD = pointD;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getShape1() {
|
||||
return shape1;
|
||||
}
|
||||
|
||||
public void setShape1(@Nullable String shape1) {
|
||||
this.shape1 = shape1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getShape2() {
|
||||
return shape2;
|
||||
}
|
||||
|
||||
public void setShape2(@Nullable String shape2) {
|
||||
this.shape2 = shape2;
|
||||
}
|
||||
}
|
||||
|
||||
@Document(indexName = "test-index-user-mapping-builder")
|
||||
@ -604,76 +801,278 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Document(indexName = "completion")
|
||||
static class CompletionDocument {
|
||||
@Id private String id;
|
||||
|
||||
@CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO,
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO,
|
||||
path = "proppath") }) private Completion suggest;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Completion getSuggest() {
|
||||
return suggest;
|
||||
}
|
||||
|
||||
public void setSuggest(@Nullable Completion suggest) {
|
||||
this.suggest = suggest;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-entity-with-seq-no-primary-term-mapping-builder")
|
||||
static class EntityWithSeqNoPrimaryTerm {
|
||||
@Nullable @Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
|
||||
@Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Nullable
|
||||
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
|
||||
return seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
|
||||
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class RankFeatureEntity {
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Rank_Feature) private Integer pageRank;
|
||||
@Nullable @Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength;
|
||||
@Nullable @Field(type = FieldType.Rank_Features) private Map<String, Integer> topics;
|
||||
|
||||
@Field(type = FieldType.Rank_Feature) private Integer pageRank;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Rank_Features) private Map<String, Integer> topics;
|
||||
@Nullable
|
||||
public java.lang.Integer getPageRank() {
|
||||
return pageRank;
|
||||
}
|
||||
|
||||
public void setPageRank(@Nullable java.lang.Integer pageRank) {
|
||||
this.pageRank = pageRank;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Integer getUrlLength() {
|
||||
return urlLength;
|
||||
}
|
||||
|
||||
public void setUrlLength(@Nullable java.lang.Integer urlLength) {
|
||||
this.urlLength = urlLength;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, java.lang.Integer> getTopics() {
|
||||
return topics;
|
||||
}
|
||||
|
||||
public void setTopics(@Nullable Map<String, java.lang.Integer> topics) {
|
||||
this.topics = topics;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "termvectors-test")
|
||||
static class TermVectorFieldEntity {
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Text, termVector = TermVector.no) private String no;
|
||||
@Field(type = FieldType.Text, termVector = TermVector.yes) private String yes;
|
||||
@Field(type = FieldType.Text, termVector = TermVector.with_positions) private String with_positions;
|
||||
@Field(type = FieldType.Text, termVector = TermVector.with_offsets) private String with_offsets;
|
||||
@Field(type = FieldType.Text, termVector = TermVector.with_positions_offsets) private String with_positions_offsets;
|
||||
@Field(type = FieldType.Text,
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Text, termVector = TermVector.no) private String no;
|
||||
@Nullable @Field(type = FieldType.Text, termVector = TermVector.yes) private String yes;
|
||||
@Nullable @Field(type = FieldType.Text, termVector = TermVector.with_positions) private String with_positions;
|
||||
@Nullable @Field(type = FieldType.Text, termVector = TermVector.with_offsets) private String with_offsets;
|
||||
@Nullable @Field(type = FieldType.Text, termVector = TermVector.with_positions_offsets) private String with_positions_offsets;
|
||||
@Nullable @Field(type = FieldType.Text,
|
||||
termVector = TermVector.with_positions_payloads) private String with_positions_payloads;
|
||||
@Field(type = FieldType.Text,
|
||||
@Nullable @Field(type = FieldType.Text,
|
||||
termVector = TermVector.with_positions_offsets_payloads) private String with_positions_offsets_payloads;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getNo() {
|
||||
return no;
|
||||
}
|
||||
|
||||
public void setNo(@Nullable String no) {
|
||||
this.no = no;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getYes() {
|
||||
return yes;
|
||||
}
|
||||
|
||||
public void setYes(@Nullable String yes) {
|
||||
this.yes = yes;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getWith_positions() {
|
||||
return with_positions;
|
||||
}
|
||||
|
||||
public void setWith_positions(@Nullable String with_positions) {
|
||||
this.with_positions = with_positions;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getWith_offsets() {
|
||||
return with_offsets;
|
||||
}
|
||||
|
||||
public void setWith_offsets(@Nullable String with_offsets) {
|
||||
this.with_offsets = with_offsets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getWith_positions_offsets() {
|
||||
return with_positions_offsets;
|
||||
}
|
||||
|
||||
public void setWith_positions_offsets(@Nullable String with_positions_offsets) {
|
||||
this.with_positions_offsets = with_positions_offsets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getWith_positions_payloads() {
|
||||
return with_positions_payloads;
|
||||
}
|
||||
|
||||
public void setWith_positions_payloads(@Nullable String with_positions_payloads) {
|
||||
this.with_positions_payloads = with_positions_payloads;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getWith_positions_offsets_payloads() {
|
||||
return with_positions_offsets_payloads;
|
||||
}
|
||||
|
||||
public void setWith_positions_offsets_payloads(@Nullable String with_positions_offsets_payloads) {
|
||||
this.with_positions_offsets_payloads = with_positions_offsets_payloads;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "wildcard-test")
|
||||
static class WildcardEntity {
|
||||
@Nullable @Field(type = Wildcard) private String wildcardWithoutParams;
|
||||
@Nullable @Field(type = Wildcard, nullValue = "WILD", ignoreAbove = 42) private String wildcardWithParams;
|
||||
|
||||
@Nullable
|
||||
public String getWildcardWithoutParams() {
|
||||
return wildcardWithoutParams;
|
||||
}
|
||||
|
||||
public void setWildcardWithoutParams(@Nullable String wildcardWithoutParams) {
|
||||
this.wildcardWithoutParams = wildcardWithoutParams;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getWildcardWithParams() {
|
||||
return wildcardWithParams;
|
||||
}
|
||||
|
||||
public void setWildcardWithParams(@Nullable String wildcardWithParams) {
|
||||
this.wildcardWithParams = wildcardWithParams;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "disabled-entity-mapping")
|
||||
@Mapping(enabled = false)
|
||||
static class DisabledMappingEntity {
|
||||
@Id private String id;
|
||||
@Field(type = Text) private String text;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text) private String text;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "disabled-property-mapping")
|
||||
static class DisabledMappingProperty {
|
||||
@Id private String id;
|
||||
@Field(type = Text) private String text;
|
||||
@Mapping(enabled = false) @Field(type = Object) private Object object;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text) private String text;
|
||||
@Nullable @Mapping(enabled = false) @Field(type = Object) private Object object;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Object getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
public void setObject(@Nullable java.lang.Object object) {
|
||||
this.object = object;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "densevector-test")
|
||||
static class DenseVectorEntity {
|
||||
@Id private String id;
|
||||
@Field(type = Dense_Vector, dims = 3) private float[] dense_vector;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Dense_Vector, dims = 3) private float[] dense_vector;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public float[] getDense_vector() {
|
||||
return dense_vector;
|
||||
}
|
||||
|
||||
public void setDense_vector(@Nullable float[] dense_vector) {
|
||||
this.dense_vector = dense_vector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,6 @@ import static org.skyscreamer.jsonassert.JSONAssert.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.Object;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Double;
|
||||
import java.lang.Integer;
|
||||
@ -649,19 +642,31 @@ public class MappingBuilderUnitTests extends MappingContextBaseTests {
|
||||
assertEquals(expected, mapping, false);
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "ignore-above-index")
|
||||
static class IgnoreAboveEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Keyword, ignoreAbove = 10) private String message;
|
||||
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Keyword, ignoreAbove = 10) private String message;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class FieldNameEntity {
|
||||
|
||||
@Document(indexName = "fieldname-index")
|
||||
@ -726,68 +731,168 @@ public class MappingBuilderUnitTests extends MappingContextBaseTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||
searchAnalyzer = "standard") }) private String description;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(@Nullable Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<java.lang.Integer, Collection<String>> getBuckets() {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
public void setBuckets(@Nullable Map<java.lang.Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-simple-recursive-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class SimpleRecursiveEntity {
|
||||
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Object,
|
||||
ignoreFields = { "circularObject" }) private SimpleRecursiveEntity circularObject;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SimpleRecursiveEntity getCircularObject() {
|
||||
return circularObject;
|
||||
}
|
||||
|
||||
public void setCircularObject(@Nullable SimpleRecursiveEntity circularObject) {
|
||||
this.circularObject = circularObject;
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-copy-to-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class CopyToEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String firstName;
|
||||
@Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String lastName;
|
||||
@Nullable @Field(type = FieldType.Keyword) private String name;
|
||||
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Keyword, copyTo = "name") private String firstName;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Keyword, copyTo = "name") private String lastName;
|
||||
@Nullable
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Keyword) private String name;
|
||||
public void setFirstName(@Nullable String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(@Nullable String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-normalizer-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
@Setting(settingPath = "/settings/test-normalizer.json")
|
||||
static class NormalizerEntity {
|
||||
|
||||
@Id private String id;
|
||||
|
||||
@Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name;
|
||||
|
||||
@MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case",
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name;
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case",
|
||||
type = FieldType.Keyword, normalizer = "lower_case_normalizer") }) private String description;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
static class Author {
|
||||
|
||||
@Nullable private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
@ -825,19 +930,38 @@ public class MappingBuilderUnitTests extends MappingContextBaseTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-stock-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class StockPrice {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String symbol;
|
||||
@Nullable @Field(type = FieldType.Double) private BigDecimal price;
|
||||
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private String symbol;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Double) private BigDecimal price;
|
||||
@Nullable
|
||||
public String getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public void setSymbol(@Nullable String symbol) {
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(@Nullable BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
}
|
||||
|
||||
static class AbstractInheritedEntity {
|
||||
@ -916,31 +1040,112 @@ public class MappingBuilderUnitTests extends MappingContextBaseTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-geo-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class GeoEntity {
|
||||
|
||||
@Id private String id;
|
||||
|
||||
@Nullable @Id private String id;
|
||||
// geo shape - Spring Data
|
||||
private Box box;
|
||||
private Circle circle;
|
||||
private Polygon polygon;
|
||||
|
||||
@Nullable private Box box;
|
||||
@Nullable private Circle circle;
|
||||
@Nullable private Polygon polygon;
|
||||
// geo point - Custom implementation + Spring Data
|
||||
@GeoPointField private Point pointA;
|
||||
private GeoPoint pointB;
|
||||
@GeoPointField private String pointC;
|
||||
@GeoPointField private double[] pointD;
|
||||
|
||||
@Nullable @GeoPointField private Point pointA;
|
||||
@Nullable private GeoPoint pointB;
|
||||
@Nullable @GeoPointField private String pointC;
|
||||
@Nullable @GeoPointField private double[] pointD;
|
||||
// geo shape, until e have the classes for this, us a strng
|
||||
@GeoShapeField private String shape1;
|
||||
@GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false,
|
||||
@Nullable @GeoShapeField private String shape1;
|
||||
@Nullable @GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false,
|
||||
orientation = GeoShapeField.Orientation.clockwise) private String shape2;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Box getBox() {
|
||||
return box;
|
||||
}
|
||||
|
||||
public void setBox(@Nullable Box box) {
|
||||
this.box = box;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Circle getCircle() {
|
||||
return circle;
|
||||
}
|
||||
|
||||
public void setCircle(@Nullable Circle circle) {
|
||||
this.circle = circle;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Polygon getPolygon() {
|
||||
return polygon;
|
||||
}
|
||||
|
||||
public void setPolygon(@Nullable Polygon polygon) {
|
||||
this.polygon = polygon;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Point getPointA() {
|
||||
return pointA;
|
||||
}
|
||||
|
||||
public void setPointA(@Nullable Point pointA) {
|
||||
this.pointA = pointA;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getPointB() {
|
||||
return pointB;
|
||||
}
|
||||
|
||||
public void setPointB(@Nullable GeoPoint pointB) {
|
||||
this.pointB = pointB;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPointC() {
|
||||
return pointC;
|
||||
}
|
||||
|
||||
public void setPointC(@Nullable String pointC) {
|
||||
this.pointC = pointC;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public double[] getPointD() {
|
||||
return pointD;
|
||||
}
|
||||
|
||||
public void setPointD(@Nullable double[] pointD) {
|
||||
this.pointD = pointD;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getShape1() {
|
||||
return shape1;
|
||||
}
|
||||
|
||||
public void setShape1(@Nullable String shape1) {
|
||||
this.shape1 = shape1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getShape2() {
|
||||
return shape2;
|
||||
}
|
||||
|
||||
public void setShape2(@Nullable String shape2) {
|
||||
this.shape2 = shape2;
|
||||
}
|
||||
}
|
||||
|
||||
@Document(indexName = "test-index-field-mapping-parameters")
|
||||
@ -1022,94 +1227,309 @@ public class MappingBuilderUnitTests extends MappingContextBaseTests {
|
||||
@Nullable @Field(type = Text) private ValueObject valueObject;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Document(indexName = "completion")
|
||||
static class CompletionDocument {
|
||||
@Id private String id;
|
||||
|
||||
@CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO,
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO,
|
||||
path = "proppath") }) private Completion suggest;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Completion getSuggest() {
|
||||
return suggest;
|
||||
}
|
||||
|
||||
public void setSuggest(@Nullable Completion suggest) {
|
||||
this.suggest = suggest;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-entity-with-seq-no-primary-term-mapping-builder")
|
||||
static class EntityWithSeqNoPrimaryTerm {
|
||||
|
||||
@Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
|
||||
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
|
||||
return seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
public void setSeqNoPrimaryTerm(SeqNoPrimaryTerm seqNoPrimaryTerm) {
|
||||
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class RankFeatureEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Rank_Feature) private Integer pageRank;
|
||||
@Nullable @Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength;
|
||||
@Nullable @Field(type = FieldType.Rank_Features) private Map<String, Integer> topics;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Rank_Feature) private Integer pageRank;
|
||||
@Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength;
|
||||
@Field(type = FieldType.Rank_Features) private Map<String, Integer> topics;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Integer getPageRank() {
|
||||
return pageRank;
|
||||
}
|
||||
|
||||
public void setPageRank(@Nullable java.lang.Integer pageRank) {
|
||||
this.pageRank = pageRank;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Integer getUrlLength() {
|
||||
return urlLength;
|
||||
}
|
||||
|
||||
public void setUrlLength(@Nullable java.lang.Integer urlLength) {
|
||||
this.urlLength = urlLength;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, java.lang.Integer> getTopics() {
|
||||
return topics;
|
||||
}
|
||||
|
||||
public void setTopics(@Nullable Map<String, java.lang.Integer> topics) {
|
||||
this.topics = topics;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class DenseVectorEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Dense_Vector, dims = 16) private float[] my_vector;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Dense_Vector, dims = 16) private float[] my_vector;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public float[] getMy_vector() {
|
||||
return my_vector;
|
||||
}
|
||||
|
||||
public void setMy_vector(@Nullable float[] my_vector) {
|
||||
this.my_vector = my_vector;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Mapping(enabled = false)
|
||||
static class DisabledMappingEntity {
|
||||
@Id private String id;
|
||||
@Field(type = Text) private String text;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text) private String text;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class InvalidDisabledMappingProperty {
|
||||
@Id private String id;
|
||||
@Mapping(enabled = false) @Field(type = Text) private String text;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Mapping(enabled = false) @Field(type = Text) private String text;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class DisabledMappingProperty {
|
||||
@Id private String id;
|
||||
@Field(type = Text) private String text;
|
||||
@Mapping(enabled = false) @Field(type = Object) private Object object;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text) private String text;
|
||||
@Nullable @Mapping(enabled = false) @Field(type = Object) private Object object;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Object getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
public void setObject(@Nullable java.lang.Object object) {
|
||||
this.object = object;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class TypeHintEntity {
|
||||
@Id @Field(type = Keyword) private String id;
|
||||
@Nullable @Id @Field(type = Keyword) private String id;
|
||||
@Nullable @Field(type = Nested) private NestedEntity nestedEntity;
|
||||
@Nullable @Field(type = Object) private ObjectEntity objectEntity;
|
||||
|
||||
@Field(type = Nested) private NestedEntity nestedEntity;
|
||||
|
||||
@Field(type = Object) private ObjectEntity objectEntity;
|
||||
|
||||
@Data
|
||||
static class NestedEntity {
|
||||
@Field(type = Text) private String nestedField;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NestedEntity getNestedEntity() {
|
||||
return nestedEntity;
|
||||
}
|
||||
|
||||
public void setNestedEntity(@Nullable NestedEntity nestedEntity) {
|
||||
this.nestedEntity = nestedEntity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ObjectEntity getObjectEntity() {
|
||||
return objectEntity;
|
||||
}
|
||||
|
||||
public void setObjectEntity(@Nullable ObjectEntity objectEntity) {
|
||||
this.objectEntity = objectEntity;
|
||||
}
|
||||
|
||||
static class NestedEntity {
|
||||
@Nullable @Field(type = Text) private String nestedField;
|
||||
|
||||
@Nullable
|
||||
public String getNestedField() {
|
||||
return nestedField;
|
||||
}
|
||||
|
||||
public void setNestedField(@Nullable String nestedField) {
|
||||
this.nestedField = nestedField;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class ObjectEntity {
|
||||
@Field(type = Text) private String objectField;
|
||||
@Nullable @Field(type = Text) private String objectField;
|
||||
|
||||
@Nullable
|
||||
public String getObjectField() {
|
||||
return objectField;
|
||||
}
|
||||
|
||||
public void setObjectField(@Nullable String objectField) {
|
||||
this.objectField = objectField;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class DateFormatsEntity {
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Date) private LocalDateTime field1;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Date) private LocalDateTime field1;
|
||||
@Nullable @Field(type = FieldType.Date, format = DateFormat.basic_date) private LocalDateTime field2;
|
||||
@Nullable @Field(type = FieldType.Date, format = { DateFormat.basic_date, DateFormat.basic_time }) private LocalDateTime field3;
|
||||
@Nullable @Field(type = FieldType.Date, pattern = "dd.MM.uuuu") private LocalDateTime field4;
|
||||
@Nullable @Field(type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") private LocalDateTime field5;
|
||||
|
||||
@Field(type = FieldType.Date, format = DateFormat.basic_date) private LocalDateTime field2;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Date,
|
||||
format = { DateFormat.basic_date, DateFormat.basic_time }) private LocalDateTime field3;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Date, pattern = "dd.MM.uuuu") private LocalDateTime field4;
|
||||
@Nullable
|
||||
public LocalDateTime getField1() {
|
||||
return field1;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") private LocalDateTime field5;
|
||||
public void setField1(@Nullable LocalDateTime field1) {
|
||||
this.field1 = field1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LocalDateTime getField2() {
|
||||
return field2;
|
||||
}
|
||||
|
||||
public void setField2(@Nullable LocalDateTime field2) {
|
||||
this.field2 = field2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LocalDateTime getField3() {
|
||||
return field3;
|
||||
}
|
||||
|
||||
public void setField3(@Nullable LocalDateTime field3) {
|
||||
this.field3 = field3;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LocalDateTime getField4() {
|
||||
return field4;
|
||||
}
|
||||
|
||||
public void setField4(@Nullable LocalDateTime field4) {
|
||||
this.field4 = field4;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LocalDateTime getField5() {
|
||||
return field5;
|
||||
}
|
||||
|
||||
public void setField5(@Nullable LocalDateTime field5) {
|
||||
this.field5 = field5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ package org.springframework.data.elasticsearch.core.index;
|
||||
import static org.skyscreamer.jsonassert.JSONAssert.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -30,6 +28,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.core.MappingContextBaseTests;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Jakub Vavrik
|
||||
@ -52,19 +51,47 @@ public class SimpleElasticsearchDateMappingTests extends MappingContextBaseTests
|
||||
assertEquals(EXPECTED_MAPPING, mapping, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Jakub Vavrik
|
||||
*/
|
||||
@Data
|
||||
@Document(indexName = "test-index-date-mapping-core", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleDateMappingEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||
@Nullable @Field(type = Date, format = {}, pattern = "dd.MM.uuuu hh:mm") private LocalDateTime customFormatDate;
|
||||
@Nullable @Field(type = FieldType.Date, format = DateFormat.basic_date) private LocalDateTime basicFormatDate;
|
||||
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Field(type = Date, format = {}, pattern = "dd.MM.uuuu hh:mm") private LocalDateTime customFormatDate;
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Date, format = DateFormat.basic_date) private LocalDateTime basicFormatDate;
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LocalDateTime getCustomFormatDate() {
|
||||
return customFormatDate;
|
||||
}
|
||||
|
||||
public void setCustomFormatDate(@Nullable LocalDateTime customFormatDate) {
|
||||
this.customFormatDate = customFormatDate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LocalDateTime getBasicFormatDate() {
|
||||
return basicFormatDate;
|
||||
}
|
||||
|
||||
public void setBasicFormatDate(@Nullable LocalDateTime basicFormatDate) {
|
||||
this.basicFormatDate = basicFormatDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@ -45,6 +40,7 @@ import org.springframework.data.elasticsearch.core.query.Query;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -84,10 +80,9 @@ public class EntityCustomConversionIntegrationTests {
|
||||
@DisplayName("should use CustomConversions on entity")
|
||||
void shouldUseCustomConversionsOnEntity() {
|
||||
|
||||
Entity entity = Entity.builder() //
|
||||
.value("hello") //
|
||||
.location(GeoJsonPoint.of(8.0, 42.7)) //
|
||||
.build();
|
||||
Entity entity = new Entity();
|
||||
entity.setValue("hello"); //
|
||||
entity.setLocation(GeoJsonPoint.of(8.0, 42.7));
|
||||
|
||||
org.springframework.data.elasticsearch.core.document.Document document = org.springframework.data.elasticsearch.core.document.Document
|
||||
.create();
|
||||
@ -102,10 +97,9 @@ public class EntityCustomConversionIntegrationTests {
|
||||
@DisplayName("should store and load entity from Elasticsearch")
|
||||
void shouldStoreAndLoadEntityFromElasticsearch() {
|
||||
|
||||
Entity entity = Entity.builder() //
|
||||
.value("hello") //
|
||||
.location(GeoJsonPoint.of(8.0, 42.7)) //
|
||||
.build();
|
||||
Entity entity = new Entity();
|
||||
entity.setValue("hello"); //
|
||||
entity.setLocation(GeoJsonPoint.of(8.0, 42.7));
|
||||
|
||||
Entity savedEntity = operations.save(entity);
|
||||
|
||||
@ -115,14 +109,49 @@ public class EntityCustomConversionIntegrationTests {
|
||||
assertThat(foundEntity).isEqualTo(entity);
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Document(indexName = "entity-with-custom-conversions")
|
||||
static class Entity {
|
||||
private String value;
|
||||
private GeoJsonPoint location;
|
||||
@Nullable private String value;
|
||||
@Nullable private GeoJsonPoint location;
|
||||
|
||||
@Nullable
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(@Nullable String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoJsonPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable GeoJsonPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Entity))
|
||||
return false;
|
||||
|
||||
Entity entity = (Entity) o;
|
||||
|
||||
if (value != null ? !value.equals(entity.value) : entity.value != null)
|
||||
return false;
|
||||
return location != null ? location.equals(entity.location) : entity.location == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = value != null ? value.hashCode() : 0;
|
||||
result = 31 * result + (location != null ? location.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@WritingConverter
|
||||
|
@ -15,11 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
@ -32,15 +30,14 @@ import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
|
||||
import org.springframework.data.elasticsearch.core.ReactiveIndexOperations;
|
||||
import org.springframework.data.elasticsearch.core.SearchHits;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||
import org.springframework.data.elasticsearch.core.query.Query;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.mapping.model.FieldNamingStrategy;
|
||||
import org.springframework.data.mapping.model.SnakeCaseFieldNamingStrategy;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
/**
|
||||
* @author Peter-Josef Meisch
|
||||
@ -73,7 +70,9 @@ public class FieldNamingStrategyIntegrationReactiveTest {
|
||||
@DisplayName("should use configured FieldNameStrategy")
|
||||
void shouldUseConfiguredFieldNameStrategy() {
|
||||
|
||||
Entity entity = new Entity.EntityBuilder().id("42").someText("the text to be searched").build();
|
||||
Entity entity = new Entity();
|
||||
entity.setId("42");
|
||||
entity.setSomeText("the text to be searched");
|
||||
operations.save(entity).block();
|
||||
|
||||
// use a native query here to prevent automatic property name matching
|
||||
@ -84,11 +83,27 @@ public class FieldNamingStrategyIntegrationReactiveTest {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Document(indexName = "field-naming-strategy-test")
|
||||
static class Entity {
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Text) private String someText;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Text) private String someText;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSomeText() {
|
||||
return someText;
|
||||
}
|
||||
|
||||
public void setSomeText(@Nullable String someText) {
|
||||
this.someText = someText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,6 @@ package org.springframework.data.elasticsearch.core.mapping;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
@ -42,6 +39,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTem
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.mapping.model.FieldNamingStrategy;
|
||||
import org.springframework.data.mapping.model.SnakeCaseFieldNamingStrategy;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -81,7 +79,9 @@ public class FieldNamingStrategyIntegrationTest {
|
||||
@DisplayName("should use configured FieldNameStrategy")
|
||||
void shouldUseConfiguredFieldNameStrategy() {
|
||||
|
||||
Entity entity = new Entity.EntityBuilder().id("42").someText("the text to be searched").build();
|
||||
Entity entity = new Entity();
|
||||
entity.setId("42");
|
||||
entity.setSomeText("the text to be searched");
|
||||
operations.save(entity);
|
||||
|
||||
// use a native query here to prevent automatic property name matching
|
||||
@ -91,11 +91,27 @@ public class FieldNamingStrategyIntegrationTest {
|
||||
assertThat(searchHits.getTotalHits()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Document(indexName = "field-naming-strategy-test")
|
||||
static class Entity {
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Text) private String someText;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Text) private String someText;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSomeText() {
|
||||
return someText;
|
||||
}
|
||||
|
||||
public void setSomeText(@Nullable String someText) {
|
||||
this.someText = someText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,6 @@ package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
@ -264,30 +262,61 @@ public class SimpleElasticsearchPersistentPropertyUnitTests {
|
||||
@Nullable @Field(type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") List<LocalDate> localDateList;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class SeqNoPrimaryTermProperty {
|
||||
SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
String string;
|
||||
@Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Nullable private String string;
|
||||
|
||||
@Nullable
|
||||
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
|
||||
return seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
|
||||
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
|
||||
public void setString(@Nullable String string) {
|
||||
this.string = string;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class DateFieldWithNoFormat {
|
||||
@Field(type = FieldType.Date) LocalDateTime datetime;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class DateFieldWithCustomFormatAndNoPattern {
|
||||
@Field(type = FieldType.Date, format = DateFormat.custom, pattern = "") LocalDateTime datetime;
|
||||
@Nullable private @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "") LocalDateTime datetime;
|
||||
|
||||
@Nullable
|
||||
public LocalDateTime getDatetime() {
|
||||
return datetime;
|
||||
}
|
||||
|
||||
public void setDatetime(@Nullable LocalDateTime datetime) {
|
||||
this.datetime = datetime;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class DateNanosFieldWithNoFormat {
|
||||
@Field(type = FieldType.Date_Nanos) LocalDateTime datetime;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class FieldNamingStrategyEntity {
|
||||
private String withoutCustomFieldName;
|
||||
@Nullable private String withoutCustomFieldName;
|
||||
@Field(name = "CUStomFIEldnAME") private String withCustomFieldName;
|
||||
|
||||
@Nullable
|
||||
public String getWithoutCustomFieldName() {
|
||||
return withoutCustomFieldName;
|
||||
}
|
||||
|
||||
public void setWithoutCustomFieldName(@Nullable String withoutCustomFieldName) {
|
||||
this.withoutCustomFieldName = withoutCustomFieldName;
|
||||
}
|
||||
|
||||
public String getWithCustomFieldName() {
|
||||
return withCustomFieldName;
|
||||
}
|
||||
|
||||
public void setWithCustomFieldName(String withCustomFieldName) {
|
||||
this.withCustomFieldName = withCustomFieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,6 @@ package org.springframework.data.elasticsearch.core.paginating;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -42,6 +38,7 @@ import org.springframework.data.elasticsearch.core.SearchHit;
|
||||
import org.springframework.data.elasticsearch.core.query.Query;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -57,8 +54,8 @@ public class ReactiveSearchAfterIntegrationTests {
|
||||
@DisplayName("should read pages with search_after")
|
||||
void shouldReadPagesWithSearchAfter() {
|
||||
|
||||
List<Entity> entities = IntStream.rangeClosed(1, 10)
|
||||
.mapToObj(i -> Entity.builder().id((long) i).message("message " + i).build()).collect(Collectors.toList());
|
||||
List<Entity> entities = IntStream.rangeClosed(1, 10).mapToObj(i -> new Entity((long) i, "message " + i))
|
||||
.collect(Collectors.toList());
|
||||
operations.saveAll(Mono.just(entities), Entity.class).blockLast();
|
||||
|
||||
Query query = Query.findAll();
|
||||
@ -87,14 +84,54 @@ public class ReactiveSearchAfterIntegrationTests {
|
||||
assertThat(foundEntities).containsExactlyElementsOf(entities);
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-search-after")
|
||||
private static class Entity {
|
||||
@Id private Long id;
|
||||
@Field(type = FieldType.Text) private String message;
|
||||
@Nullable @Id private Long id;
|
||||
@Nullable @Field(type = FieldType.Text) private String message;
|
||||
|
||||
public Entity(@Nullable Long id, @Nullable String message) {
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Entity))
|
||||
return false;
|
||||
|
||||
Entity entity = (Entity) o;
|
||||
|
||||
if (id != null ? !id.equals(entity.id) : entity.id != null)
|
||||
return false;
|
||||
return message != null ? message.equals(entity.message) : entity.message == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.core.paginating;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -41,6 +36,7 @@ import org.springframework.data.elasticsearch.core.SearchHits;
|
||||
import org.springframework.data.elasticsearch.core.query.Query;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -56,8 +52,8 @@ public class SearchAfterIntegrationTests {
|
||||
@DisplayName("should read pages with search_after")
|
||||
void shouldReadPagesWithSearchAfter() {
|
||||
|
||||
List<Entity> entities = IntStream.rangeClosed(1, 10)
|
||||
.mapToObj(i -> Entity.builder().id((long) i).message("message " + i).build()).collect(Collectors.toList());
|
||||
List<Entity> entities = IntStream.rangeClosed(1, 10).mapToObj(i -> new Entity((long) i, "message " + i))
|
||||
.collect(Collectors.toList());
|
||||
operations.save(entities);
|
||||
|
||||
Query query = Query.findAll();
|
||||
@ -86,13 +82,53 @@ public class SearchAfterIntegrationTests {
|
||||
assertThat(foundEntities).containsExactlyElementsOf(entities);
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-search-after")
|
||||
private static class Entity {
|
||||
@Id private Long id;
|
||||
@Field(type = FieldType.Text) private String message;
|
||||
@Nullable @Id private Long id;
|
||||
@Nullable @Field(type = FieldType.Text) private String message;
|
||||
|
||||
public Entity(@Nullable Long id, @Nullable String message) {
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Entity))
|
||||
return false;
|
||||
|
||||
Entity entity = (Entity) o;
|
||||
|
||||
if (id != null ? !id.equals(entity.id) : entity.id != null)
|
||||
return false;
|
||||
return message != null ? message.equals(entity.message) : entity.message == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.lang.Long;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -47,6 +41,7 @@ import org.springframework.data.elasticsearch.core.SearchHits;
|
||||
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.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -761,23 +756,18 @@ public class CriteriaQueryIntegrationTests {
|
||||
@Test
|
||||
public void shouldReturnDocumentAboveMinimalScoreGivenCriteria() {
|
||||
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
|
||||
indexQueries.add(buildIndex(SampleEntity.builder().id("1").message("ab").build()));
|
||||
indexQueries.add(buildIndex(SampleEntity.builder().id("2").message("bc").build()));
|
||||
indexQueries.add(buildIndex(SampleEntity.builder().id("3").message("ac").build()));
|
||||
|
||||
indexQueries.add(buildIndex(new SampleEntity("1", "ab")));
|
||||
indexQueries.add(buildIndex(new SampleEntity("2", "bc")));
|
||||
indexQueries.add(buildIndex(new SampleEntity("3", "ac")));
|
||||
operations.bulkIndex(indexQueries, index);
|
||||
indexOperations.refresh();
|
||||
|
||||
// when
|
||||
CriteriaQuery criteriaQuery = new CriteriaQuery(
|
||||
new Criteria("message").contains("a").or(new Criteria("message").contains("b")));
|
||||
criteriaQuery.setMinScore(2.0F);
|
||||
SearchHits<SampleEntity> searchHits = operations.search(criteriaQuery, SampleEntity.class, index);
|
||||
|
||||
// then
|
||||
assertThat(searchHits.getTotalHits()).isEqualTo(1);
|
||||
assertThat(searchHits.getSearchHit(0).getContent().getMessage()).isEqualTo("ab");
|
||||
}
|
||||
@ -807,18 +797,65 @@ public class CriteriaQueryIntegrationTests {
|
||||
assertThat(sampleEntity1).isNotNull();
|
||||
}
|
||||
|
||||
@Builder
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Document(indexName = "test-index-sample-core-query", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
|
||||
@Nullable
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
private int rate;
|
||||
@Version private Long version;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
public SampleEntity() {
|
||||
}
|
||||
|
||||
public SampleEntity(@Nullable String id, @Nullable String message) {
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,6 @@ package org.springframework.data.elasticsearch.core.routing;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -94,34 +90,94 @@ class DefaultRoutingResolverUnitTest {
|
||||
assertThat(routing).isEqualTo("route 42");
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Document(indexName = "routing-resolver-test")
|
||||
@Routing("theRouting")
|
||||
static class ValidRoutingEntity {
|
||||
@Id private String id;
|
||||
private String theRouting;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String theRouting;
|
||||
|
||||
public ValidRoutingEntity(@Nullable String id, @Nullable String theRouting) {
|
||||
this.id = id;
|
||||
this.theRouting = theRouting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTheRouting() {
|
||||
return theRouting;
|
||||
}
|
||||
|
||||
public void setTheRouting(@Nullable String theRouting) {
|
||||
this.theRouting = theRouting;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Document(indexName = "routing-resolver-test")
|
||||
@Routing(value = "@spelRouting.getRouting(#entity)")
|
||||
static class ValidSpelRoutingEntity {
|
||||
@Id private String id;
|
||||
private String theRouting;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String theRouting;
|
||||
|
||||
public ValidSpelRoutingEntity(@Nullable String id, @Nullable String theRouting) {
|
||||
this.id = id;
|
||||
this.theRouting = theRouting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTheRouting() {
|
||||
return theRouting;
|
||||
}
|
||||
|
||||
public void setTheRouting(@Nullable String theRouting) {
|
||||
this.theRouting = theRouting;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Document(indexName = "routing-resolver-test")
|
||||
@Routing("unknownProperty")
|
||||
static class InvalidRoutingEntity {
|
||||
@Id private String id;
|
||||
private String theRouting;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String theRouting;
|
||||
|
||||
public InvalidRoutingEntity(@Nullable String id, @Nullable String theRouting) {
|
||||
this.id = id;
|
||||
this.theRouting = theRouting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTheRouting() {
|
||||
return theRouting;
|
||||
}
|
||||
|
||||
public void setTheRouting(@Nullable String theRouting) {
|
||||
this.theRouting = theRouting;
|
||||
}
|
||||
}
|
||||
|
||||
static class SpelRouting {
|
||||
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.core.routing;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.elasticsearch.cluster.routing.Murmur3HashFunction;
|
||||
@ -86,7 +81,7 @@ public class ElasticsearchOperationsRoutingTests {
|
||||
@DisplayName("should store data with different routing and be able to get it")
|
||||
void shouldStoreDataWithDifferentRoutingAndBeAbleToGetIt() {
|
||||
|
||||
RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build();
|
||||
RoutingEntity entity = new RoutingEntity(ID_1, ID_2);
|
||||
operations.save(entity);
|
||||
indexOps.refresh();
|
||||
|
||||
@ -99,7 +94,7 @@ public class ElasticsearchOperationsRoutingTests {
|
||||
@DisplayName("should store data with different routing and be able to delete it")
|
||||
void shouldStoreDataWithDifferentRoutingAndBeAbleToDeleteIt() {
|
||||
|
||||
RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build();
|
||||
RoutingEntity entity = new RoutingEntity(ID_1, ID_2);
|
||||
operations.save(entity);
|
||||
indexOps.refresh();
|
||||
|
||||
@ -112,7 +107,7 @@ public class ElasticsearchOperationsRoutingTests {
|
||||
@DisplayName("should store data with different routing and get the routing in the search result")
|
||||
void shouldStoreDataWithDifferentRoutingAndGetTheRoutingInTheSearchResult() {
|
||||
|
||||
RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build();
|
||||
RoutingEntity entity = new RoutingEntity(ID_1, ID_2);
|
||||
operations.save(entity);
|
||||
indexOps.refresh();
|
||||
|
||||
@ -122,14 +117,54 @@ public class ElasticsearchOperationsRoutingTests {
|
||||
assertThat(searchHits.getSearchHit(0).getRouting()).isEqualTo(ID_2);
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Document(indexName = INDEX, shards = 5)
|
||||
@Routing("routing")
|
||||
static class RoutingEntity {
|
||||
@Id private String id;
|
||||
private String routing;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String routing;
|
||||
|
||||
public RoutingEntity(@Nullable String id, @Nullable String routing) {
|
||||
this.id = id;
|
||||
this.routing = routing;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getRouting() {
|
||||
return routing;
|
||||
}
|
||||
|
||||
public void setRouting(@Nullable String routing) {
|
||||
this.routing = routing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof RoutingEntity))
|
||||
return false;
|
||||
|
||||
RoutingEntity that = (RoutingEntity) o;
|
||||
|
||||
if (id != null ? !id.equals(that.id) : that.id != null)
|
||||
return false;
|
||||
return routing != null ? routing.equals(that.routing) : that.routing == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (routing != null ? routing.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.core.routing;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ -84,7 +79,7 @@ public class ReactiveElasticsearchOperationsRoutingTests {
|
||||
@DisplayName("should store data with different routing and be able to get it")
|
||||
void shouldStoreDataWithDifferentRoutingAndBeAbleToGetIt() {
|
||||
|
||||
RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build();
|
||||
RoutingEntity entity = new RoutingEntity(ID_1, ID_2);
|
||||
operations.save(entity).then(indexOps.refresh()).block();
|
||||
|
||||
RoutingEntity savedEntity = operations.withRouting(RoutingResolver.just(ID_2)).get(entity.id, RoutingEntity.class)
|
||||
@ -97,7 +92,7 @@ public class ReactiveElasticsearchOperationsRoutingTests {
|
||||
@DisplayName("should store data with different routing and be able to delete it")
|
||||
void shouldStoreDataWithDifferentRoutingAndBeAbleToDeleteIt() {
|
||||
|
||||
RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build();
|
||||
RoutingEntity entity = new RoutingEntity(ID_1, ID_2);
|
||||
operations.save(entity).then(indexOps.refresh()).block();
|
||||
|
||||
String deletedId = operations.withRouting(RoutingResolver.just(ID_2)).delete(entity.id, IndexCoordinates.of(INDEX))
|
||||
@ -110,7 +105,7 @@ public class ReactiveElasticsearchOperationsRoutingTests {
|
||||
@DisplayName("should store data with different routing and get the routing in the search result")
|
||||
void shouldStoreDataWithDifferentRoutingAndGetTheRoutingInTheSearchResult() {
|
||||
|
||||
RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build();
|
||||
RoutingEntity entity = new RoutingEntity(ID_1, ID_2);
|
||||
operations.save(entity).then(indexOps.refresh()).block();
|
||||
|
||||
List<SearchHit<RoutingEntity>> searchHits = operations.search(Query.findAll(), RoutingEntity.class).collectList()
|
||||
@ -120,14 +115,54 @@ public class ReactiveElasticsearchOperationsRoutingTests {
|
||||
assertThat(searchHits.get(0).getRouting()).isEqualTo(ID_2);
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Document(indexName = INDEX, shards = 5)
|
||||
@Routing("routing")
|
||||
static class RoutingEntity {
|
||||
@Id private String id;
|
||||
private String routing;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String routing;
|
||||
|
||||
public RoutingEntity(@Nullable String id, @Nullable String routing) {
|
||||
this.id = id;
|
||||
this.routing = routing;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getRouting() {
|
||||
return routing;
|
||||
}
|
||||
|
||||
public void setRouting(@Nullable String routing) {
|
||||
this.routing = routing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof RoutingEntity))
|
||||
return false;
|
||||
|
||||
RoutingEntity that = (RoutingEntity) o;
|
||||
|
||||
if (id != null ? !id.equals(that.id) : that.id != null)
|
||||
return false;
|
||||
return routing != null ? routing.equals(that.routing) : that.routing == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (routing != null ? routing.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.immutable;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
/**
|
||||
* @author Young Gu
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public interface ImmutableElasticsearchRepository extends CrudRepository<ImmutableEntity, String> {}
|
@ -17,9 +17,6 @@ package org.springframework.data.elasticsearch.immutable;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@ -95,16 +92,21 @@ public class ImmutableElasticsearchRepositoryTests {
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Document(indexName = "test-index-immutable")
|
||||
@NoArgsConstructor(force = true)
|
||||
@Getter
|
||||
static class ImmutableEntity {
|
||||
private final String id, name;
|
||||
|
||||
public ImmutableEntity(String name) {
|
||||
|
||||
this.id = null;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2021 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.immutable;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
|
||||
/**
|
||||
* @author Young Gu
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Document(indexName = "test-index-immutable")
|
||||
@NoArgsConstructor(force = true)
|
||||
@Getter
|
||||
public class ImmutableEntity {
|
||||
private final String id, name;
|
||||
|
||||
public ImmutableEntity(String name) {
|
||||
|
||||
this.id = null;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.repositories.cdi;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@ -157,39 +152,129 @@ public class CdiRepositoryTests {
|
||||
* @author Mohsin Husen
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-product-cdi-repository", replicas = 0, refreshInterval = "-1")
|
||||
static class Product {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private List<String> title;
|
||||
@Nullable private String name;
|
||||
@Nullable private String description;
|
||||
@Nullable private String text;
|
||||
@Nullable private List<String> categories;
|
||||
@Nullable private Float weight;
|
||||
@Nullable @Field(type = FieldType.Float) private Float price;
|
||||
@Nullable private Integer popularity;
|
||||
@Nullable private boolean available;
|
||||
@Nullable private String location;
|
||||
@Nullable private Date lastModified;
|
||||
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private List<String> title;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private String name;
|
||||
@Nullable
|
||||
public List<String> getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
private String description;
|
||||
public void setTitle(@Nullable List<String> title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
private String text;
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private List<String> categories;
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private Float weight;
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Float) private Float price;
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private Integer popularity;
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
private boolean available;
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
private String location;
|
||||
@Nullable
|
||||
public List<String> getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
private Date lastModified;
|
||||
public void setCategories(@Nullable List<String> categories) {
|
||||
this.categories = categories;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Float getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(@Nullable Float weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(@Nullable Float price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getPopularity() {
|
||||
return popularity;
|
||||
}
|
||||
|
||||
public void setPopularity(@Nullable Integer popularity) {
|
||||
this.popularity = popularity;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getLastModified() {
|
||||
return lastModified;
|
||||
}
|
||||
|
||||
public void setLastModified(@Nullable Date lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-person-cdi-repository", replicas = 0, refreshInterval = "-1")
|
||||
static class Person {
|
||||
|
||||
@ -203,37 +288,106 @@ public class CdiRepositoryTests {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-cdi-repository", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||
searchAnalyzer = "standard") }) private String description;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(@Nullable Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<Integer, Collection<String>> getBuckets() {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
public void setBuckets(@Nullable Map<Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
static class Car {
|
||||
@Nullable private String name;
|
||||
@Nullable private String model;
|
||||
|
||||
private String name;
|
||||
private String model;
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(@Nullable String model) {
|
||||
this.model = model;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Author {
|
||||
@Nullable private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ package org.springframework.data.elasticsearch.repositories.complex.custommethod
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -35,6 +33,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTem
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -80,14 +79,40 @@ public class ComplexCustomMethodRepositoryTests {
|
||||
assertThat(result).isEqualTo("2+2=4");
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-sample-repositories-complex-custommethod-autowiring", replicas = 0,
|
||||
refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
|
||||
@Nullable
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ package org.springframework.data.elasticsearch.repositories.complex.custommethod
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -35,6 +33,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTem
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -78,12 +77,37 @@ public class ComplexCustomMethodRepositoryManualWiringTests {
|
||||
assertThat(result).isEqualTo("3+3=6");
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-sample-repository-manual-wiring", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.lang.Long;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -66,6 +61,7 @@ import org.springframework.data.geo.Box;
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Metrics;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
@ -1635,21 +1631,87 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
assertThat(count).isEqualTo(20);
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-sample-repositories-custom-method", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
|
||||
@Nullable
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Field(type = Keyword) private String keyword;
|
||||
private int rate;
|
||||
private boolean available;
|
||||
private GeoPoint location;
|
||||
@Version private Long version;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable @Field(type = Keyword) private String keyword;
|
||||
@Nullable private int rate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable private GeoPoint location;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(@Nullable String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable GeoPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,12 +17,6 @@ package org.springframework.data.elasticsearch.repositories.geo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -47,6 +41,7 @@ import org.springframework.data.geo.Box;
|
||||
import org.springframework.data.geo.Circle;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.geo.Polygon;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -84,8 +79,11 @@ public class SpringDataGeoRepositoryTests {
|
||||
|
||||
// given
|
||||
Point point = new Point(15, 25);
|
||||
GeoEntity entity = GeoEntity.builder().pointA(point).pointB(new GeoPoint(point.getX(), point.getY()))
|
||||
.pointC(toGeoString(point)).pointD(toGeoArray(point)).build();
|
||||
GeoEntity entity = new GeoEntity();
|
||||
entity.setPointA(point);
|
||||
entity.setPointB(new GeoPoint(point.getX(), point.getY()));
|
||||
entity.setPointC(toGeoString(point));
|
||||
entity.setPointD(toGeoArray(point));
|
||||
|
||||
// when
|
||||
GeoEntity saved = repository.save(entity);
|
||||
@ -112,32 +110,90 @@ public class SpringDataGeoRepositoryTests {
|
||||
return new double[] { point.getX(), point.getY() };
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-geo-repository", replicas = 0, refreshInterval = "-1")
|
||||
static class GeoEntity {
|
||||
|
||||
@Id private String id;
|
||||
|
||||
@Nullable @Id private String id;
|
||||
// geo shape - Spring Data
|
||||
private Box box;
|
||||
private Circle circle;
|
||||
private Polygon polygon;
|
||||
|
||||
@Nullable private Box box;
|
||||
@Nullable private Circle circle;
|
||||
@Nullable private Polygon polygon;
|
||||
// geo point - Custom implementation + Spring Data
|
||||
@GeoPointField private Point pointA;
|
||||
@Nullable @GeoPointField private Point pointA;
|
||||
@Nullable private GeoPoint pointB;
|
||||
@Nullable @GeoPointField private String pointC;
|
||||
@Nullable @GeoPointField private double[] pointD;
|
||||
|
||||
private GeoPoint pointB;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@GeoPointField private String pointC;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@GeoPointField private double[] pointD;
|
||||
@Nullable
|
||||
public Box getBox() {
|
||||
return box;
|
||||
}
|
||||
|
||||
public void setBox(@Nullable Box box) {
|
||||
this.box = box;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Circle getCircle() {
|
||||
return circle;
|
||||
}
|
||||
|
||||
public void setCircle(@Nullable Circle circle) {
|
||||
this.circle = circle;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Polygon getPolygon() {
|
||||
return polygon;
|
||||
}
|
||||
|
||||
public void setPolygon(@Nullable Polygon polygon) {
|
||||
this.polygon = polygon;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Point getPointA() {
|
||||
return pointA;
|
||||
}
|
||||
|
||||
public void setPointA(@Nullable Point pointA) {
|
||||
this.pointA = pointA;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getPointB() {
|
||||
return pointB;
|
||||
}
|
||||
|
||||
public void setPointB(@Nullable GeoPoint pointB) {
|
||||
this.pointB = pointB;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPointC() {
|
||||
return pointC;
|
||||
}
|
||||
|
||||
public void setPointC(@Nullable String pointC) {
|
||||
this.pointC = pointC;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public double[] getPointD() {
|
||||
return pointD;
|
||||
}
|
||||
|
||||
public void setPointD(@Nullable double[] pointD) {
|
||||
this.pointD = pointD;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,12 +19,6 @@ package org.springframework.data.elasticsearch.repositories.nestedobject;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -48,6 +42,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTes
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -101,26 +96,60 @@ public class InnerObjectTests {
|
||||
assertThat(bookRepository.findById(id)).isNotNull();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Nordine Bittich
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||
searchAnalyzer = "standard") }) private String description;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(@Nullable Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<Integer, Collection<String>> getBuckets() {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
public void setBuckets(@Nullable Map<Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
public interface SampleElasticSearchBookRepository extends ElasticsearchRepository<Book, String> {}
|
||||
|
@ -17,8 +17,6 @@ package org.springframework.data.elasticsearch.repositories.synonym;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -40,6 +38,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTes
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -95,23 +94,31 @@ public class SynonymRepositoryTests {
|
||||
assertThat(synonymEntities).hasSize(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
@Data
|
||||
@Document(indexName = "test-index-synonym")
|
||||
@Setting(settingPath = "/synonyms/settings.json")
|
||||
@Mapping(mappingPath = "/synonyms/mappings.json")
|
||||
static class SynonymEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String text;
|
||||
|
||||
@Id private String id;
|
||||
private String text;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SynonymRepository
|
||||
*
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
interface SynonymRepository extends ElasticsearchRepository<SynonymEntity, String> {}
|
||||
}
|
||||
|
@ -18,11 +18,6 @@ package org.springframework.data.elasticsearch.repositories.uuidkeyed;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -55,6 +50,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTes
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -549,24 +545,139 @@ public class UUIDElasticsearchRepositoryTests {
|
||||
return sampleEntities;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Data
|
||||
@Document(indexName = "test-index-uuid-keyed", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntityUUIDKeyed {
|
||||
@Nullable @Id private UUID id;
|
||||
@Nullable private String type;
|
||||
@Nullable @Field(type = FieldType.Text, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable @ScriptedField private Long scriptedRate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable private String highlightedMessage;
|
||||
@Nullable private GeoPoint location;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Id private UUID id;
|
||||
private String type;
|
||||
@Field(type = FieldType.Text, fielddata = true) private String message;
|
||||
private int rate;
|
||||
@ScriptedField private Long scriptedRate;
|
||||
private boolean available;
|
||||
private String highlightedMessage;
|
||||
@Nullable
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private GeoPoint location;
|
||||
public void setId(@Nullable UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Version private Long version;
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getScriptedRate() {
|
||||
return scriptedRate;
|
||||
}
|
||||
|
||||
public void setScriptedRate(@Nullable Long scriptedRate) {
|
||||
this.scriptedRate = scriptedRate;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getHighlightedMessage() {
|
||||
return highlightedMessage;
|
||||
}
|
||||
|
||||
public void setHighlightedMessage(@Nullable String highlightedMessage) {
|
||||
this.highlightedMessage = highlightedMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(@Nullable GeoPoint location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof SampleEntityUUIDKeyed))
|
||||
return false;
|
||||
|
||||
SampleEntityUUIDKeyed that = (SampleEntityUUIDKeyed) o;
|
||||
|
||||
if (rate != that.rate)
|
||||
return false;
|
||||
if (available != that.available)
|
||||
return false;
|
||||
if (id != null ? !id.equals(that.id) : that.id != null)
|
||||
return false;
|
||||
if (type != null ? !type.equals(that.type) : that.type != null)
|
||||
return false;
|
||||
if (message != null ? !message.equals(that.message) : that.message != null)
|
||||
return false;
|
||||
if (scriptedRate != null ? !scriptedRate.equals(that.scriptedRate) : that.scriptedRate != null)
|
||||
return false;
|
||||
if (highlightedMessage != null ? !highlightedMessage.equals(that.highlightedMessage)
|
||||
: that.highlightedMessage != null)
|
||||
return false;
|
||||
if (location != null ? !location.equals(that.location) : that.location != null)
|
||||
return false;
|
||||
return version != null ? version.equals(that.version) : that.version == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (type != null ? type.hashCode() : 0);
|
||||
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||
result = 31 * result + rate;
|
||||
result = 31 * result + (scriptedRate != null ? scriptedRate.hashCode() : 0);
|
||||
result = 31 * result + (available ? 1 : 0);
|
||||
result = 31 * result + (highlightedMessage != null ? highlightedMessage.hashCode() : 0);
|
||||
result = 31 * result + (location != null ? location.hashCode() : 0);
|
||||
result = 31 * result + (version != null ? version.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.repository.config;
|
||||
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -34,6 +29,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -62,15 +58,37 @@ public class ReactiveElasticsearchRepositoriesRegistrarTests {
|
||||
|
||||
interface ReactiveSampleEntityRepository extends ReactiveElasticsearchRepository<SampleEntity, String> {}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-sample-reactive-repositories-registrar", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,6 @@ package org.springframework.data.elasticsearch.repository.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
@ -80,13 +76,37 @@ public class ElasticsearchQueryMethodUnitTests {
|
||||
Long validCountQueryResult(String name);
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Document(indexName = "query-method-unit-tests")
|
||||
private static class Person {
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable private String firstName;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(@Nullable String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,6 @@ package org.springframework.data.elasticsearch.repository.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -169,64 +163,85 @@ public class ElasticsearchStringQueryUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Nordine Bittich
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-query-unittest", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||
searchAnalyzer = "standard") }) private String description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
static class Car {
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String model;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(@Nullable Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<Integer, Collection<String>> getBuckets() {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
public void setBuckets(@Nullable Map<Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
static class Car {
|
||||
@Nullable private String name;
|
||||
@Nullable private String model;
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
public void setModel(@Nullable String model) {
|
||||
this.model = model;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
static class Author {
|
||||
|
||||
@Nullable private String id;
|
||||
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.repository.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@ -220,64 +215,85 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Nordine Bittich
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-reactive-repository-query", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||
searchAnalyzer = "standard") }) private String description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
static class Car {
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String model;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(@Nullable Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<Integer, Collection<String>> getBuckets() {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
public void setBuckets(@Nullable Map<Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
static class Car {
|
||||
@Nullable private String name;
|
||||
@Nullable private String model;
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
public void setModel(@Nullable String model) {
|
||||
this.model = model;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
static class Author {
|
||||
|
||||
@Nullable private String id;
|
||||
|
@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.repository.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@ -224,64 +219,85 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Nordine Bittich
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-reactive-repository-string-query", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
@Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
|
||||
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||
searchAnalyzer = "standard") }) private String description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
static class Car {
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String model;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(@Nullable Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<Integer, Collection<String>> getBuckets() {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
public void setBuckets(@Nullable Map<Integer, Collection<String>> buckets) {
|
||||
this.buckets = buckets;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
static class Car {
|
||||
@Nullable private String name;
|
||||
@Nullable private String model;
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
public void setModel(@Nullable String model) {
|
||||
this.model = model;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
static class Author {
|
||||
|
||||
@Nullable private String id;
|
||||
|
@ -17,12 +17,6 @@ package org.springframework.data.elasticsearch.repository.query.keywords;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -76,18 +70,12 @@ class QueryKeywordsTests {
|
||||
indexOperations = operations.indexOps(Product.class);
|
||||
IndexInitializer.init(indexOperations);
|
||||
|
||||
Product product1 = Product.builder().id("1").name("Sugar").text("Cane sugar").price(1.0f).available(false)
|
||||
.sortName("sort5").build();
|
||||
Product product2 = Product.builder().id("2").name("Sugar").text("Cane sugar").price(1.2f).available(true)
|
||||
.sortName("sort4").build();
|
||||
Product product3 = Product.builder().id("3").name("Sugar").text("Beet sugar").price(1.1f).available(true)
|
||||
.sortName("sort3").build();
|
||||
Product product4 = Product.builder().id("4").name("Salt").text("Rock salt").price(1.9f).available(true)
|
||||
.sortName("sort2").build();
|
||||
Product product5 = Product.builder().id("5").name("Salt").text("Sea salt").price(2.1f).available(false)
|
||||
.sortName("sort1").build();
|
||||
Product product6 = Product.builder().id("6").name(null).text("no name").price(3.4f).available(false)
|
||||
.sortName("sort0").build();
|
||||
Product product1 = new Product("1", "Sugar", "Cane sugar", 1.0f, false, "sort5");
|
||||
Product product2 = new Product("2", "Sugar", "Cane sugar", 1.2f, true, "sort4");
|
||||
Product product3 = new Product("3", "Sugar", "Beet sugar", 1.1f, true, "sort3");
|
||||
Product product4 = new Product("4", "Salt", "Rock salt", 1.9f, true, "sort2");
|
||||
Product product5 = new Product("5", "Salt", "Sea salt", 2.1f, false, "sort1");
|
||||
Product product6 = new Product("6", null, "no name", 3.4f, false, "sort0");
|
||||
|
||||
repository.saveAll(Arrays.asList(product1, product2, product3, product4, product5, product6));
|
||||
}
|
||||
@ -285,34 +273,79 @@ class QueryKeywordsTests {
|
||||
assertThat(products).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Mohsin Husen
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-product-query-keywords", replicas = 0, refreshInterval = "-1")
|
||||
static class Product {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Keyword) private String text;
|
||||
@Nullable @Field(type = FieldType.Float) private Float price;
|
||||
@Nullable private boolean available;
|
||||
@Nullable @Field(name = "sort-name", type = FieldType.Keyword) private String sortName;
|
||||
|
||||
@Id private String id;
|
||||
public Product(@Nullable String id, @Nullable String name, @Nullable String text, @Nullable Float price,
|
||||
boolean available, @Nullable String sortName) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.text = text;
|
||||
this.price = price;
|
||||
this.available = available;
|
||||
this.sortName = sortName;
|
||||
}
|
||||
|
||||
private String name;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Keyword) private String text;
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Field(type = FieldType.Float) private Float price;
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private boolean available;
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Field(name = "sort-name", type = FieldType.Keyword) private String sortName;
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(@Nullable Float price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSortName() {
|
||||
return sortName;
|
||||
}
|
||||
|
||||
public void setSortName(@Nullable String sortName) {
|
||||
this.sortName = sortName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by akonczak on 04/09/15.
|
||||
*/
|
||||
interface ProductRepository extends ElasticsearchRepository<Product, String> {
|
||||
|
||||
List<Product> findByName(@Nullable String name);
|
||||
|
@ -20,13 +20,9 @@ import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.Long;
|
||||
import java.lang.Object;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -59,6 +55,7 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.data.util.StreamUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -76,8 +73,7 @@ class SimpleElasticsearchRepositoryIntegrationTests {
|
||||
|
||||
@Configuration
|
||||
@Import({ ElasticsearchRestTemplateConfiguration.class })
|
||||
@EnableElasticsearchRepositories(
|
||||
basePackages = { "org.springframework.data.elasticsearch.repository.support" },
|
||||
@EnableElasticsearchRepositories(basePackages = { "org.springframework.data.elasticsearch.repository.support" },
|
||||
considerNestedRepositories = true)
|
||||
static class Config {}
|
||||
|
||||
@ -681,32 +677,101 @@ class SimpleElasticsearchRepositoryIntegrationTests {
|
||||
return sampleEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Chris White
|
||||
* @author Sascha Woo
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-sample-simple-repository", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
private int rate;
|
||||
private boolean available;
|
||||
@Version private Long version;
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
SampleEntity that = (SampleEntity) o;
|
||||
|
||||
if (rate != that.rate)
|
||||
return false;
|
||||
if (available != that.available)
|
||||
return false;
|
||||
if (id != null ? !id.equals(that.id) : that.id != null)
|
||||
return false;
|
||||
if (type != null ? !type.equals(that.type) : that.type != null)
|
||||
return false;
|
||||
if (message != null ? !message.equals(that.message) : that.message != null)
|
||||
return false;
|
||||
return version != null ? version.equals(that.version) : that.version == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (type != null ? type.hashCode() : 0);
|
||||
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||
result = 31 * result + rate;
|
||||
result = 31 * result + (available ? 1 : 0);
|
||||
result = 31 * result + (version != null ? version.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
interface SampleElasticsearchRepository extends ElasticsearchRepository<SampleEntity, String> {
|
||||
|
||||
long deleteSampleEntityById(String id);
|
||||
|
@ -19,11 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.core.query.Query.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.elasticsearch.core.query.ByQueryResponse;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@ -63,6 +58,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearc
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -97,7 +93,7 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void saveShouldSaveSingleEntity() {
|
||||
|
||||
repository.save(SampleEntity.builder().build()) //
|
||||
repository.save(new SampleEntity()) //
|
||||
.map(SampleEntity::getId) //
|
||||
.flatMap(this::documentWithIdExistsInIndex) //
|
||||
.as(StepVerifier::create) //
|
||||
@ -111,10 +107,8 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void saveShouldComputeMultipleEntities() {
|
||||
|
||||
repository
|
||||
.saveAll(Arrays.asList(SampleEntity.builder().build(), SampleEntity.builder().build(),
|
||||
SampleEntity.builder().build())) //
|
||||
.map(SampleEntity::getId) //
|
||||
repository.saveAll(Arrays.asList(new SampleEntity(), new SampleEntity(), new SampleEntity()))
|
||||
/**/.map(SampleEntity::getId) //
|
||||
.flatMap(this::documentWithIdExistsInIndex) //
|
||||
.as(StepVerifier::create) //
|
||||
.expectNext(true) //
|
||||
@ -133,9 +127,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void findShouldRetrieveSingleEntityById() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), //
|
||||
SampleEntity.builder().id("id-two").build(), //
|
||||
SampleEntity.builder().id("id-three").build()) //
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
|
||||
repository.findById("id-two").as(StepVerifier::create)//
|
||||
@ -146,9 +140,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void findByIdShouldCompleteIfNothingFound() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), //
|
||||
SampleEntity.builder().id("id-two").build(), //
|
||||
SampleEntity.builder().id("id-three").build()) //
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
|
||||
repository.findById("does-not-exist").as(StepVerifier::create) //
|
||||
@ -160,7 +154,7 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
// make sure to be above the default page size of the Query interface
|
||||
int count = DEFAULT_PAGE_SIZE * 2;
|
||||
bulkIndex(IntStream.range(1, count + 1) //
|
||||
.mapToObj(it -> SampleEntity.builder().id(String.valueOf(it)).build()) //
|
||||
.mapToObj(it -> new SampleEntity(String.valueOf(it))) //
|
||||
.toArray(SampleEntity[]::new)) //
|
||||
.block();
|
||||
|
||||
@ -178,9 +172,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void findAllByIdShouldRetrieveMatchingDocuments() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), //
|
||||
SampleEntity.builder().id("id-two").build(), //
|
||||
SampleEntity.builder().id("id-three").build()) //
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
|
||||
repository.findAllById(Arrays.asList("id-one", "id-two")) //
|
||||
@ -193,9 +187,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void findAllByIdShouldCompleteWhenNothingFound() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), //
|
||||
SampleEntity.builder().id("id-two").build(), //
|
||||
SampleEntity.builder().id("id-three").build()) //
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
|
||||
repository.findAllById(Arrays.asList("can't", "touch", "this")) //
|
||||
@ -206,9 +200,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-717
|
||||
void shouldReturnFluxOfSearchHit() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("message").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "message"), //
|
||||
new SampleEntity("id-three", "message")) //
|
||||
.block();
|
||||
|
||||
repository.queryAllByMessage("message") //
|
||||
@ -221,9 +215,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-717
|
||||
void shouldReturnFluxOfSearchHitForStringQuery() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("message").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "message"), //
|
||||
new SampleEntity("id-three", "message")) //
|
||||
.block();
|
||||
|
||||
repository.queryByMessageWithString("message") //
|
||||
@ -236,9 +230,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-372
|
||||
void shouldReturnHighlightsOnAnnotatedMethod() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("message").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "message"), //
|
||||
new SampleEntity("id-three", "message")) //
|
||||
.block();
|
||||
|
||||
repository.queryAllByMessage("message") //
|
||||
@ -254,9 +248,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-372
|
||||
void shouldReturnHighlightsOnAnnotatedStringQueryMethod() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("message").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "message"), //
|
||||
new SampleEntity("id-three", "message")) //
|
||||
.block();
|
||||
|
||||
repository.queryByMessageWithString("message") //
|
||||
@ -279,8 +273,8 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void countShouldCountDocuments() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), //
|
||||
SampleEntity.builder().id("id-two").build()) //
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two")) //
|
||||
.block();
|
||||
|
||||
repository.count().as(StepVerifier::create).expectNext(2L).verifyComplete();
|
||||
@ -289,9 +283,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void existsByIdShouldReturnTrueIfExists() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
|
||||
repository.existsById("id-two") //
|
||||
@ -303,9 +297,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void existsByIdShouldReturnFalseIfNotExists() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
|
||||
repository.existsById("wrecking ball") //
|
||||
@ -317,9 +311,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void countShouldCountMatchingDocuments() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()).block();
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")).block();
|
||||
|
||||
repository.countAllByMessage("test") //
|
||||
.as(StepVerifier::create) //
|
||||
@ -331,9 +325,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@DisplayName("should count with string query")
|
||||
void shouldCountWithStringQuery() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()).block();
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")).block();
|
||||
|
||||
repository.retrieveCountByText("test") //
|
||||
.as(StepVerifier::create) //
|
||||
@ -344,9 +338,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void existsShouldReturnTrueIfExists() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
|
||||
repository.existsAllByMessage("message") //
|
||||
@ -358,9 +352,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void existsShouldReturnFalseIfNotExists() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
|
||||
repository.existsAllByMessage("these days") //
|
||||
@ -372,8 +366,8 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void deleteByIdShouldCompleteIfNothingDeleted() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), //
|
||||
SampleEntity.builder().id("id-two").build()) //
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two")) //
|
||||
.block();
|
||||
|
||||
repository.deleteById("does-not-exist").as(StepVerifier::create).verifyComplete();
|
||||
@ -389,8 +383,8 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void deleteByIdShouldDeleteEntry() {
|
||||
|
||||
SampleEntity toBeDeleted = SampleEntity.builder().id("id-two").build();
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), toBeDeleted) //
|
||||
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
||||
bulkIndex(new SampleEntity("id-one"), toBeDeleted) //
|
||||
.block();
|
||||
|
||||
repository.deleteById(toBeDeleted.getId()).as(StepVerifier::create).verifyComplete();
|
||||
@ -401,8 +395,8 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-976
|
||||
void deleteAllByIdShouldDeleteEntry() {
|
||||
|
||||
SampleEntity toBeDeleted = SampleEntity.builder().id("id-two").build();
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), toBeDeleted) //
|
||||
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
||||
bulkIndex(new SampleEntity("id-one"), toBeDeleted) //
|
||||
.block();
|
||||
|
||||
repository.deleteAllById(Collections.singletonList(toBeDeleted.getId())).as(StepVerifier::create).verifyComplete();
|
||||
@ -413,8 +407,8 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void deleteShouldDeleteEntry() {
|
||||
|
||||
SampleEntity toBeDeleted = SampleEntity.builder().id("id-two").build();
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), toBeDeleted) //
|
||||
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
||||
bulkIndex(new SampleEntity("id-one"), toBeDeleted) //
|
||||
.block();
|
||||
|
||||
repository.delete(toBeDeleted).as(StepVerifier::create).verifyComplete();
|
||||
@ -425,9 +419,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void deleteAllShouldDeleteGivenEntries() {
|
||||
|
||||
SampleEntity toBeDeleted = SampleEntity.builder().id("id-one").build();
|
||||
SampleEntity hangInThere = SampleEntity.builder().id("id-two").build();
|
||||
SampleEntity toBeDeleted2 = SampleEntity.builder().id("id-three").build();
|
||||
SampleEntity toBeDeleted = new SampleEntity("id-one");
|
||||
SampleEntity hangInThere = new SampleEntity("id-two");
|
||||
SampleEntity toBeDeleted2 = new SampleEntity("id-three");
|
||||
|
||||
bulkIndex(toBeDeleted, hangInThere, toBeDeleted2) //
|
||||
.block();
|
||||
@ -442,9 +436,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void deleteAllShouldDeleteAllEntries() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").build(), //
|
||||
SampleEntity.builder().id("id-two").build(), //
|
||||
SampleEntity.builder().id("id-three").build()) //
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
|
||||
repository.deleteAll().as(StepVerifier::create).verifyComplete();
|
||||
@ -458,9 +452,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void derivedFinderMethodShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
|
||||
repository.findAllByMessageLike("test") //
|
||||
@ -472,9 +466,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void derivedFinderMethodShouldBeExecutedCorrectlyWhenGivenPublisher() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
|
||||
repository.findAllByMessage(Mono.just("test")) //
|
||||
@ -486,9 +480,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void derivedFinderWithDerivedSortMethodShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("test").rate(3).build(), //
|
||||
SampleEntity.builder().id("id-two").message("test test").rate(1).build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").rate(2).build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||
new SampleEntity("id-two", "test test", 1), //
|
||||
new SampleEntity("id-three", "test test", 2)) //
|
||||
.block();
|
||||
|
||||
repository.findAllByMessageLikeOrderByRate("test") //
|
||||
@ -502,9 +496,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void derivedFinderMethodWithSortParameterShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("test").rate(3).build(), //
|
||||
SampleEntity.builder().id("id-two").message("test test").rate(1).build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").rate(2).build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||
new SampleEntity("id-two", "test test", 1), //
|
||||
new SampleEntity("id-three", "test test", 2)) //
|
||||
.block();
|
||||
|
||||
repository.findAllByMessage("test", Sort.by(Order.asc("rate"))) //
|
||||
@ -518,9 +512,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void derivedFinderMethodWithPageableParameterShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("test").rate(3).build(), //
|
||||
SampleEntity.builder().id("id-two").message("test test").rate(1).build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").rate(2).build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||
new SampleEntity("id-two", "test test", 1), //
|
||||
new SampleEntity("id-three", "test test", 2)) //
|
||||
.block();
|
||||
|
||||
repository.findAllByMessage("test", PageRequest.of(0, 2, Sort.by(Order.asc("rate")))) //
|
||||
@ -533,9 +527,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void derivedFinderMethodReturningMonoShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
|
||||
repository.findFirstByMessageLike("test") //
|
||||
@ -547,9 +541,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void annotatedFinderMethodShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
|
||||
repository.findAllViaAnnotatedQueryByMessageLike("test") //
|
||||
@ -561,9 +555,9 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
@Test // DATAES-519
|
||||
void derivedDeleteMethodShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), //
|
||||
SampleEntity.builder().id("id-two").message("test message").build(), //
|
||||
SampleEntity.builder().id("id-three").message("test test").build()) //
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
|
||||
repository.deleteAllByMessage("message") //
|
||||
@ -614,25 +608,82 @@ class SimpleReactiveElasticsearchRepositoryTests {
|
||||
Mono<Long> retrieveCountByText(String message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Chris White
|
||||
* @author Sascha Woo
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = INDEX, replicas = 0, refreshInterval = "-1")
|
||||
static class SampleEntity {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Nullable @Field(type = Text, store = true, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable private boolean available;
|
||||
@Nullable @Version private Long version;
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = Text, store = true, fielddata = true) private String message;
|
||||
private int rate;
|
||||
private boolean available;
|
||||
@Version private Long version;
|
||||
public SampleEntity() {}
|
||||
|
||||
public SampleEntity(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public SampleEntity(@Nullable String id, @Nullable String message) {
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public SampleEntity(@Nullable String id, @Nullable String message, int rate) {
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@Nullable String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.lang.Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(@Nullable java.lang.Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
f6bbf833798e7af0055b94865a46440e
|
@ -0,0 +1 @@
|
||||
59ddfc2b714be7918808eacecc5739b8d277e60e
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>999999</version>
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
63317ccd46b6663ff35cb142e05dce10
|
@ -0,0 +1 @@
|
||||
db353983c68ade94ae7e08acfacc0fc21ed8b64b
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<versioning>
|
||||
<release>999999</release>
|
||||
<versions>
|
||||
<version>999999</version>
|
||||
</versions>
|
||||
<lastUpdated>20210321155422</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
@ -0,0 +1 @@
|
||||
998d3b8876980a3ef5a90adc982cc727
|
@ -0,0 +1 @@
|
||||
f4090a49c6eec680c075130b68bf8ee48aac4e94
|
Loading…
x
Reference in New Issue
Block a user