mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-01 09:42:11 +00:00
DATAES-935 - Setup integration tests separate from unit tests.
Original PR: #528
This commit is contained in:
parent
502bdb40a3
commit
e200791dc2
6
Jenkinsfile
vendored
6
Jenkinsfile
vendored
@ -32,7 +32,7 @@ pipeline {
|
|||||||
sh 'mkdir -p /tmp/jenkins-home'
|
sh 'mkdir -p /tmp/jenkins-home'
|
||||||
sh 'chown -R 1001:1001 .'
|
sh 'chown -R 1001:1001 .'
|
||||||
sh 'rm -rf ?'
|
sh 'rm -rf ?'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Dsort -U -B'
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list verify -Dsort -U -B'
|
||||||
sh 'chown -R 1001:1001 .'
|
sh 'chown -R 1001:1001 .'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ pipeline {
|
|||||||
sh 'mkdir -p /tmp/jenkins-home'
|
sh 'mkdir -p /tmp/jenkins-home'
|
||||||
sh 'chown -R 1001:1001 .'
|
sh 'chown -R 1001:1001 .'
|
||||||
sh 'rm -rf ?'
|
sh 'rm -rf ?'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B'
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list verify -Dsort -U -B'
|
||||||
sh 'chown -R 1001:1001 .'
|
sh 'chown -R 1001:1001 .'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ pipeline {
|
|||||||
sh 'mkdir -p /tmp/jenkins-home'
|
sh 'mkdir -p /tmp/jenkins-home'
|
||||||
sh 'chown -R 1001:1001 .'
|
sh 'chown -R 1001:1001 .'
|
||||||
sh 'rm -rf ?'
|
sh 'rm -rf ?'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B'
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list verify -Dsort -U -B'
|
||||||
sh 'chown -R 1001:1001 .'
|
sh 'chown -R 1001:1001 .'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
713
pom.xml
713
pom.xml
@ -1,396 +1,419 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-elasticsearch</artifactId>
|
<artifactId>spring-data-elasticsearch</artifactId>
|
||||||
<version>4.1.0-SNAPSHOT</version>
|
<version>4.1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data.build</groupId>
|
<groupId>org.springframework.data.build</groupId>
|
||||||
<artifactId>spring-data-parent</artifactId>
|
<artifactId>spring-data-parent</artifactId>
|
||||||
<version>2.4.0-SNAPSHOT</version>
|
<version>2.4.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<name>Spring Data Elasticsearch</name>
|
<name>Spring Data Elasticsearch</name>
|
||||||
<description>Spring Data Implementation for Elasticsearch</description>
|
<description>Spring Data Implementation for Elasticsearch</description>
|
||||||
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<commonslang>2.6</commonslang>
|
<commonslang>2.6</commonslang>
|
||||||
<elasticsearch>7.9.1</elasticsearch>
|
<elasticsearch>7.9.1</elasticsearch>
|
||||||
<log4j>2.13.3</log4j>
|
<log4j>2.13.3</log4j>
|
||||||
<netty>4.1.50.Final</netty>
|
<netty>4.1.50.Final</netty>
|
||||||
<springdata.commons>2.4.0-SNAPSHOT</springdata.commons>
|
<springdata.commons>2.4.0-SNAPSHOT</springdata.commons>
|
||||||
<testcontainers>1.14.3</testcontainers>
|
<testcontainers>1.14.3</testcontainers>
|
||||||
<java-module-name>spring.data.elasticsearch</java-module-name>
|
<java-module-name>spring.data.elasticsearch</java-module-name>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>biomedcentral</id>
|
<id>biomedcentral</id>
|
||||||
<name>BioMed Central Development Team</name>
|
<name>BioMed Central Development Team</name>
|
||||||
<timezone>+0</timezone>
|
<timezone>+0</timezone>
|
||||||
</developer>
|
</developer>
|
||||||
<developer>
|
<developer>
|
||||||
<id>cstrobl</id>
|
<id>cstrobl</id>
|
||||||
<name>Christoph Strobl</name>
|
<name>Christoph Strobl</name>
|
||||||
<email>cstrobl at pivotal.io</email>
|
<email>cstrobl at pivotal.io</email>
|
||||||
<organization>Pivotal</organization>
|
<organization>Pivotal</organization>
|
||||||
<organizationUrl>https://www.pivotal.io</organizationUrl>
|
<organizationUrl>https://www.pivotal.io</organizationUrl>
|
||||||
<roles>
|
<roles>
|
||||||
<role>Developer</role>
|
<role>Developer</role>
|
||||||
</roles>
|
</roles>
|
||||||
<timezone>+1</timezone>
|
<timezone>+1</timezone>
|
||||||
</developer>
|
</developer>
|
||||||
<developer>
|
<developer>
|
||||||
<id>mpaluch</id>
|
<id>mpaluch</id>
|
||||||
<name>Mark Paluch</name>
|
<name>Mark Paluch</name>
|
||||||
<email>mpaluch at pivotal.io</email>
|
<email>mpaluch at pivotal.io</email>
|
||||||
<organization>Pivotal</organization>
|
<organization>Pivotal</organization>
|
||||||
<organizationUrl>https://www.pivotal.io</organizationUrl>
|
<organizationUrl>https://www.pivotal.io</organizationUrl>
|
||||||
<roles>
|
<roles>
|
||||||
<role>Developer</role>
|
<role>Developer</role>
|
||||||
</roles>
|
</roles>
|
||||||
<timezone>+1</timezone>
|
<timezone>+1</timezone>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
||||||
<connection>scm:git:git://github.com/spring-projects/spring-data-elasticsearch.git</connection>
|
<connection>scm:git:git://github.com/spring-projects/spring-data-elasticsearch.git</connection>
|
||||||
<developerConnection>scm:git:ssh://git@github.com/spring-projects/spring-data-elasticsearch.git
|
<developerConnection>scm:git:ssh://git@github.com/spring-projects/spring-data-elasticsearch.git
|
||||||
</developerConnection>
|
</developerConnection>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>Bamboo</system>
|
<system>Bamboo</system>
|
||||||
<url>https://build.spring.io/browse/SPRINGDATAES</url>
|
<url>https://build.spring.io/browse/SPRINGDATAES</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>JIRA</system>
|
<system>JIRA</system>
|
||||||
<url>https://jira.spring.io/browse/DATAES</url>
|
<url>https://jira.spring.io/browse/DATAES</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-bom</artifactId>
|
<artifactId>netty-bom</artifactId>
|
||||||
<version>${netty}</version>
|
<version>${netty}</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context</artifactId>
|
<artifactId>spring-context</artifactId>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>commons-logging</groupId>
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-tx</artifactId>
|
<artifactId>spring-tx</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SPRING DATA -->
|
<!-- SPRING DATA -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-commons</artifactId>
|
<artifactId>spring-data-commons</artifactId>
|
||||||
<version>${springdata.commons}</version>
|
<version>${springdata.commons}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Reactive Infrastructure -->
|
<!-- Reactive Infrastructure -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-webflux</artifactId>
|
<artifactId>spring-webflux</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.projectreactor.netty</groupId>
|
<groupId>io.projectreactor.netty</groupId>
|
||||||
<artifactId>reactor-netty-http</artifactId>
|
<artifactId>reactor-netty-http</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.projectreactor</groupId>
|
<groupId>io.projectreactor</groupId>
|
||||||
<artifactId>reactor-test</artifactId>
|
<artifactId>reactor-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- APACHE -->
|
<!-- APACHE -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-lang</groupId>
|
<groupId>commons-lang</groupId>
|
||||||
<artifactId>commons-lang</artifactId>
|
<artifactId>commons-lang</artifactId>
|
||||||
<version>${commonslang}</version>
|
<version>${commonslang}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JODA Time -->
|
<!-- JODA Time -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>joda-time</artifactId>
|
||||||
<version>${jodatime}</version>
|
<version>${jodatime}</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Elasticsearch -->
|
<!-- Elasticsearch -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.elasticsearch.client</groupId>
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
<artifactId>transport</artifactId>
|
<artifactId>transport</artifactId>
|
||||||
<version>${elasticsearch}</version>
|
<version>${elasticsearch}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>commons-logging</groupId>
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<!-- required by elasticsearch -->
|
<!-- required by elasticsearch -->
|
||||||
<groupId>org.elasticsearch.plugin</groupId>
|
<groupId>org.elasticsearch.plugin</groupId>
|
||||||
<artifactId>transport-netty4-client</artifactId>
|
<artifactId>transport-netty4-client</artifactId>
|
||||||
<version>${elasticsearch}</version>
|
<version>${elasticsearch}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.elasticsearch.client</groupId>
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
||||||
<version>${elasticsearch}</version>
|
<version>${elasticsearch}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>commons-logging</groupId>
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>log4j-over-slf4j</artifactId>
|
<artifactId>log4j-over-slf4j</artifactId>
|
||||||
<version>${slf4j}</version>
|
<version>${slf4j}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-core</artifactId>
|
<artifactId>log4j-core</artifactId>
|
||||||
<version>${log4j}</version>
|
<version>${log4j}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Jackson JSON Mapper -->
|
<!-- Jackson JSON Mapper -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- CDI -->
|
<!-- CDI -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.enterprise</groupId>
|
<groupId>javax.enterprise</groupId>
|
||||||
<artifactId>cdi-api</artifactId>
|
<artifactId>cdi-api</artifactId>
|
||||||
<version>${cdi}</version>
|
<version>${cdi}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>spring-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.openwebbeans.test</groupId>
|
<groupId>org.apache.openwebbeans.test</groupId>
|
||||||
<artifactId>cditest-owb</artifactId>
|
<artifactId>cditest-owb</artifactId>
|
||||||
<version>1.2.8</version>
|
<version>1.2.8</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
|
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-atinject_1.0_spec</artifactId>
|
<artifactId>geronimo-atinject_1.0_spec</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.skyscreamer</groupId>
|
<groupId>org.skyscreamer</groupId>
|
||||||
<artifactId>jsonassert</artifactId>
|
<artifactId>jsonassert</artifactId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.tomakehurst</groupId>
|
<groupId>com.github.tomakehurst</groupId>
|
||||||
<artifactId>wiremock-jre8</artifactId>
|
<artifactId>wiremock-jre8</artifactId>
|
||||||
<version>2.26.3</version>
|
<version>2.26.3</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<!-- these exclusions are needed because of Elasticsearch JarHell-->
|
<!-- these exclusions are needed because of Elasticsearch JarHell-->
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>commons-logging</groupId>
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.ow2.asm</groupId>
|
<groupId>org.ow2.asm</groupId>
|
||||||
<artifactId>asm</artifactId>
|
<artifactId>asm</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Upgrade xbean to 4.5 to prevent incompatibilities due to ASM versions -->
|
<!-- Upgrade xbean to 4.5 to prevent incompatibilities due to ASM versions -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.xbean</groupId>
|
<groupId>org.apache.xbean</groupId>
|
||||||
<artifactId>xbean-asm5-shaded</artifactId>
|
<artifactId>xbean-asm5-shaded</artifactId>
|
||||||
<version>4.5</version>
|
<version>4.5</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-junit-jupiter</artifactId>
|
<artifactId>mockito-junit-jupiter</artifactId>
|
||||||
<version>${mockito}</version>
|
<version>${mockito}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testcontainers</groupId>
|
<groupId>org.testcontainers</groupId>
|
||||||
<artifactId>elasticsearch</artifactId>
|
<artifactId>elasticsearch</artifactId>
|
||||||
<version>${testcontainers}</version>
|
<version>${testcontainers}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/versions.properties</include>
|
<include>**/versions.properties</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>false</filtering>
|
<filtering>false</filtering>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/versions.properties</exclude>
|
<exclude>**/versions.properties</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<!--
|
<!--
|
||||||
please do not remove this configuration for surefire - we need that to avoid issue with jar hell
|
please do not remove this configuration for surefire - we need that to avoid issue with jar hell
|
||||||
-->
|
-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useSystemClassLoader>true</useSystemClassLoader>
|
<useSystemClassLoader>true</useSystemClassLoader>
|
||||||
<useFile>false</useFile>
|
<useFile>false</useFile>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*Tests.java</include>
|
<include>**/*Tests.java</include>
|
||||||
<include>**/*Test.java</include>
|
<include>**/*Test.java</include>
|
||||||
</includes>
|
</includes>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<es.set.netty.runtime.available.processors>false</es.set.netty.runtime.available.processors>
|
<es.set.netty.runtime.available.processors>false</es.set.netty.runtime.available.processors>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
<executions>
|
||||||
<plugin>
|
<!-- the default-test execution runs only the unit tests -->
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<execution>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<id>default-test</id>
|
||||||
</plugin>
|
<phase>test</phase>
|
||||||
<plugin>
|
<goals>
|
||||||
<groupId>org.asciidoctor</groupId>
|
<goal>test</goal>
|
||||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
</goals>
|
||||||
</plugin>
|
<configuration>
|
||||||
</plugins>
|
<excludedGroups>integration-test</excludedGroups>
|
||||||
</build>
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<!-- execution to run the integration tests -->
|
||||||
|
<execution>
|
||||||
|
<id>integration-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<groups>integration-test</groups>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin> <plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.asciidoctor</groupId>
|
||||||
|
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
|
||||||
<id>ci</id>
|
<id>ci</id>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<checkstyleRules>
|
<checkstyleRules>
|
||||||
<module name="Checker">
|
<module name="Checker">
|
||||||
|
|
||||||
<!-- Configure checker to use UTF-8 encoding -->
|
<!-- Configure checker to use UTF-8 encoding -->
|
||||||
<property name="charset" value="UTF-8"/>
|
<property name="charset" value="UTF-8"/>
|
||||||
|
|
||||||
<module name="io.spring.nohttp.checkstyle.check.NoHttpCheck"/>
|
<module name="io.spring.nohttp.checkstyle.check.NoHttpCheck"/>
|
||||||
</module>
|
</module>
|
||||||
</checkstyleRules>
|
</checkstyleRules>
|
||||||
<includes>**/*</includes>
|
<includes>**/*</includes>
|
||||||
<excludes>.git/**/*,target/**/*,**/target/**/*,.idea/**/*,**/spring.schemas,**/*.svg,mvnw,mvnw.cmd,**/*.policy</excludes>
|
<excludes>.git/**/*,target/**/*,**/target/**/*,.idea/**/*,**/spring.schemas,**/*.svg,mvnw,mvnw.cmd,**/*.policy</excludes>
|
||||||
<sourceDirectories>./</sourceDirectories>
|
<sourceDirectories>./</sourceDirectories>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-libs-snapshot</id>
|
<id>spring-libs-snapshot</id>
|
||||||
<url>https://repo.spring.io/libs-snapshot</url>
|
<url>https://repo.spring.io/libs-snapshot</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>spring-plugins-release</id>
|
<id>spring-plugins-release</id>
|
||||||
<url>https://repo.spring.io/plugins-release</url>
|
<url>https://repo.spring.io/plugins-release</url>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -434,7 +434,7 @@ class RequestFactoryTests {
|
|||||||
PutIndexTemplateRequest putIndexTemplateRequest = requestFactory.putIndexTemplateRequest(putTemplateRequest);
|
PutIndexTemplateRequest putIndexTemplateRequest = requestFactory.putIndexTemplateRequest(putTemplateRequest);
|
||||||
|
|
||||||
String json = requestToString(putIndexTemplateRequest);
|
String json = requestToString(putIndexTemplateRequest);
|
||||||
System.out.println(json);
|
|
||||||
assertEquals(expected, json, false);
|
assertEquals(expected, json, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,624 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013-2020 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.core.index;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||||
|
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.math.BigDecimal;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.assertj.core.data.Percentage;
|
||||||
|
import org.elasticsearch.search.suggest.completion.context.ContextMapping;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.elasticsearch.annotations.*;
|
||||||
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
|
import org.springframework.data.elasticsearch.core.IndexOperations;
|
||||||
|
import org.springframework.data.elasticsearch.core.SearchHits;
|
||||||
|
import org.springframework.data.elasticsearch.core.completion.Completion;
|
||||||
|
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||||
|
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Stuart Stevenson
|
||||||
|
* @author Jakub Vavrik
|
||||||
|
* @author Mohsin Husen
|
||||||
|
* @author Keivn Leturc
|
||||||
|
* @author Nordine Bittich
|
||||||
|
* @author Don Wellington
|
||||||
|
* @author Sascha Woo
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
|
* @author Xiao Yu
|
||||||
|
* @author Roman Puchkovskiy
|
||||||
|
*/
|
||||||
|
@SpringIntegrationTest
|
||||||
|
@ContextConfiguration(classes = { ElasticsearchRestTemplateConfiguration.class })
|
||||||
|
public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||||
|
|
||||||
|
@Autowired private ElasticsearchOperations operations;
|
||||||
|
private IndexOperations indexOperations;
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
@BeforeEach
|
||||||
|
public void deleteIndices() {
|
||||||
|
indexOperations = operations.indexOps(SimpleRecursiveEntity.class);
|
||||||
|
indexOperations.delete();
|
||||||
|
operations.indexOps(StockPrice.class).delete();
|
||||||
|
operations.indexOps(SampleInheritedEntity.class).delete();
|
||||||
|
operations.indexOps(User.class).delete();
|
||||||
|
operations.indexOps(Group.class).delete();
|
||||||
|
operations.indexOps(Book.class).delete();
|
||||||
|
operations.indexOps(NormalizerEntity.class).delete();
|
||||||
|
operations.indexOps(CopyToEntity.class).delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldNotFailOnCircularReference() {
|
||||||
|
|
||||||
|
operations.indexOps(SimpleRecursiveEntity.class).create();
|
||||||
|
indexOperations.putMapping(SimpleRecursiveEntity.class);
|
||||||
|
indexOperations.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // DATAES-530
|
||||||
|
public void shouldAddStockPriceDocumentToIndex() {
|
||||||
|
|
||||||
|
// Given
|
||||||
|
IndexOperations indexOps = operations.indexOps(StockPrice.class);
|
||||||
|
|
||||||
|
// When
|
||||||
|
indexOps.create();
|
||||||
|
indexOps.putMapping(StockPrice.class);
|
||||||
|
String symbol = "AU";
|
||||||
|
double price = 2.34;
|
||||||
|
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);
|
||||||
|
operations.indexOps(StockPrice.class).refresh();
|
||||||
|
|
||||||
|
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
|
||||||
|
SearchHits<StockPrice> result = operations.search(searchQuery, StockPrice.class, index);
|
||||||
|
|
||||||
|
// Then
|
||||||
|
assertThat(result).hasSize(1);
|
||||||
|
StockPrice entry = result.getSearchHit(0).getContent();
|
||||||
|
assertThat(entry.getSymbol()).isEqualTo(symbol);
|
||||||
|
assertThat(entry.getPrice()).isCloseTo(BigDecimal.valueOf(price), Percentage.withPercentage(0.01));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // DATAES-76
|
||||||
|
public void shouldAddSampleInheritedEntityDocumentToIndex() {
|
||||||
|
// given
|
||||||
|
IndexCoordinates index = IndexCoordinates.of("test-index-sample-inherited-mapping-builder");
|
||||||
|
IndexOperations indexOps = operations.indexOps(index);
|
||||||
|
|
||||||
|
// when
|
||||||
|
indexOps.create();
|
||||||
|
indexOps.putMapping(SampleInheritedEntity.class);
|
||||||
|
Date createdDate = new Date();
|
||||||
|
String message = "msg";
|
||||||
|
String id = "abc";
|
||||||
|
operations.index(new SampleInheritedEntityBuilder(id).createdDate(createdDate).message(message).buildIndex(),
|
||||||
|
index);
|
||||||
|
operations.indexOps(SampleInheritedEntity.class).refresh();
|
||||||
|
|
||||||
|
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
|
||||||
|
SearchHits<SampleInheritedEntity> result = operations.search(searchQuery, SampleInheritedEntity.class, index);
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertThat(result).hasSize(1);
|
||||||
|
|
||||||
|
SampleInheritedEntity entry = result.getSearchHit(0).getContent();
|
||||||
|
assertThat(entry.getCreatedDate()).isEqualTo(createdDate);
|
||||||
|
assertThat(entry.getMessage()).isEqualTo(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // DATAES-260 - StackOverflow when two reverse relationship.
|
||||||
|
public void shouldHandleReverseRelationship() {
|
||||||
|
|
||||||
|
// given
|
||||||
|
IndexOperations indexOpsUser = operations.indexOps(User.class);
|
||||||
|
indexOpsUser.create();
|
||||||
|
indexOpsUser.putMapping(User.class);
|
||||||
|
|
||||||
|
IndexOperations indexOpsGroup = operations.indexOps(Group.class);
|
||||||
|
indexOpsGroup.create();
|
||||||
|
indexOpsGroup.putMapping(Group.class);
|
||||||
|
|
||||||
|
// when
|
||||||
|
|
||||||
|
// then
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // DATAES-420
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
|
public void shouldUseBothAnalyzer() {
|
||||||
|
|
||||||
|
// given
|
||||||
|
IndexOperations indexOps = this.operations.indexOps(Book.class);
|
||||||
|
indexOps.create();
|
||||||
|
indexOps.putMapping(Book.class);
|
||||||
|
|
||||||
|
// when
|
||||||
|
Map mapping = indexOps.getMapping();
|
||||||
|
Map descriptionMapping = (Map) ((Map) mapping.get("properties")).get("description");
|
||||||
|
Map prefixDescription = (Map) ((Map) descriptionMapping.get("fields")).get("prefix");
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertThat(prefixDescription).hasSize(3);
|
||||||
|
assertThat(prefixDescription.get("type")).isEqualTo("text");
|
||||||
|
assertThat(prefixDescription.get("analyzer")).isEqualTo("stop");
|
||||||
|
assertThat(prefixDescription.get("search_analyzer")).isEqualTo("standard");
|
||||||
|
assertThat(descriptionMapping.get("type")).isEqualTo("text");
|
||||||
|
assertThat(descriptionMapping.get("analyzer")).isEqualTo("whitespace");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // DATAES-492
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public void shouldUseKeywordNormalizer() {
|
||||||
|
|
||||||
|
// given
|
||||||
|
operations.createIndex(NormalizerEntity.class);
|
||||||
|
operations.putMapping(NormalizerEntity.class);
|
||||||
|
|
||||||
|
// when
|
||||||
|
Map mapping = operations.getMapping(NormalizerEntity.class);
|
||||||
|
Map properties = (Map) mapping.get("properties");
|
||||||
|
Map fieldName = (Map) properties.get("name");
|
||||||
|
Map fieldDescriptionLowerCase = (Map) ((Map) ((Map) properties.get("description")).get("fields")).get("lower_case");
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertThat(fieldName.get("type")).isEqualTo("keyword");
|
||||||
|
assertThat(fieldName.get("normalizer")).isEqualTo("lower_case_normalizer");
|
||||||
|
assertThat(fieldDescriptionLowerCase.get("type")).isEqualTo("keyword");
|
||||||
|
assertThat(fieldDescriptionLowerCase.get("normalizer")).isEqualTo("lower_case_normalizer");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // DATAES-503
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public void shouldUseCopyTo() {
|
||||||
|
|
||||||
|
// given
|
||||||
|
IndexOperations indexOps = operations.indexOps(CopyToEntity.class);
|
||||||
|
indexOps.create();
|
||||||
|
indexOps.putMapping(CopyToEntity.class);
|
||||||
|
|
||||||
|
// when
|
||||||
|
Map mapping = indexOps.getMapping();
|
||||||
|
Map properties = (Map) mapping.get("properties");
|
||||||
|
Map fieldFirstName = (Map) properties.get("firstName");
|
||||||
|
Map fieldLastName = (Map) properties.get("lastName");
|
||||||
|
|
||||||
|
// then
|
||||||
|
List<String> copyToValue = Collections.singletonList("name");
|
||||||
|
assertThat(fieldFirstName.get("copy_to")).isEqualTo(copyToValue);
|
||||||
|
assertThat(fieldLastName.get("copy_to")).isEqualTo(copyToValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Xiao Yu
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Document(indexName = "ignore-above-index")
|
||||||
|
static class IgnoreAboveEntity {
|
||||||
|
|
||||||
|
@Id private String id;
|
||||||
|
|
||||||
|
@Field(type = FieldType.Keyword, ignoreAbove = 10) private String message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
|
*/
|
||||||
|
static class FieldNameEntity {
|
||||||
|
|
||||||
|
@Document(indexName = "fieldname-index")
|
||||||
|
static class IdEntity {
|
||||||
|
@Nullable @Id @Field("id-property") private String id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Document(indexName = "fieldname-index")
|
||||||
|
static class TextEntity {
|
||||||
|
|
||||||
|
@Nullable @Id @Field("id-property") private String id;
|
||||||
|
|
||||||
|
@Field(name = "text-property", type = FieldType.Text) //
|
||||||
|
@Nullable private String textProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Document(indexName = "fieldname-index")
|
||||||
|
static class MappingEntity {
|
||||||
|
|
||||||
|
@Nullable @Id @Field("id-property") private String id;
|
||||||
|
|
||||||
|
@Field("mapping-property") @Mapping(mappingPath = "/mappings/test-field-analyzed-mappings.json") //
|
||||||
|
@Nullable private byte[] mappingProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Document(indexName = "fieldname-index")
|
||||||
|
static class GeoPointEntity {
|
||||||
|
|
||||||
|
@Nullable @Id @Field("id-property") private String id;
|
||||||
|
|
||||||
|
@Nullable @Field("geopoint-property") private GeoPoint geoPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Document(indexName = "fieldname-index")
|
||||||
|
static class CircularEntity {
|
||||||
|
|
||||||
|
@Nullable @Id @Field("id-property") private String id;
|
||||||
|
|
||||||
|
@Nullable @Field(name = "circular-property", type = FieldType.Object, ignoreFields = { "circular-property" }) //
|
||||||
|
private CircularEntity circularProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Document(indexName = "fieldname-index")
|
||||||
|
static class CompletionEntity {
|
||||||
|
|
||||||
|
@Nullable @Id @Field("id-property") private String id;
|
||||||
|
|
||||||
|
@Nullable @Field("completion-property") @CompletionField(maxInputLength = 100) //
|
||||||
|
private Completion suggest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Document(indexName = "fieldname-index")
|
||||||
|
static class MultiFieldEntity {
|
||||||
|
|
||||||
|
@Nullable @Id @Field("id-property") private String id;
|
||||||
|
|
||||||
|
@Nullable //
|
||||||
|
@MultiField(mainField = @Field(name = "main-field", type = FieldType.Text, analyzer = "whitespace"),
|
||||||
|
otherFields = {
|
||||||
|
@InnerField(suffix = "suff-ix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) //
|
||||||
|
private String description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rizwan Idrees
|
||||||
|
* @author Mohsin Husen
|
||||||
|
* @author Nordine Bittich
|
||||||
|
*/
|
||||||
|
@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"),
|
||||||
|
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
||||||
|
searchAnalyzer = "standard") }) private String description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Stuart Stevenson
|
||||||
|
* @author Mohsin Husen
|
||||||
|
*/
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Sascha Woo
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Document(indexName = "test-copy-to-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||||
|
static class CopyToEntity {
|
||||||
|
|
||||||
|
@Id private String id;
|
||||||
|
|
||||||
|
@Field(type = FieldType.Keyword, copyTo = "name") private String firstName;
|
||||||
|
|
||||||
|
@Field(type = FieldType.Keyword, copyTo = "name") private String lastName;
|
||||||
|
|
||||||
|
@Field(type = FieldType.Keyword) private String name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Sascha Woo
|
||||||
|
*/
|
||||||
|
@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",
|
||||||
|
type = FieldType.Keyword, normalizer = "lower_case_normalizer") }) private String description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rizwan Idrees
|
||||||
|
* @author Mohsin Husen
|
||||||
|
*/
|
||||||
|
static class Author {
|
||||||
|
|
||||||
|
@Nullable private String id;
|
||||||
|
@Nullable private String name;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Kevin Leturc
|
||||||
|
*/
|
||||||
|
@Document(indexName = "test-index-sample-inherited-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||||
|
static class SampleInheritedEntity extends AbstractInheritedEntity {
|
||||||
|
|
||||||
|
@Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Kevin Leturc
|
||||||
|
*/
|
||||||
|
static class SampleInheritedEntityBuilder {
|
||||||
|
|
||||||
|
private final SampleInheritedEntity result;
|
||||||
|
|
||||||
|
public SampleInheritedEntityBuilder(String id) {
|
||||||
|
result = new SampleInheritedEntity();
|
||||||
|
result.setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SampleInheritedEntityBuilder createdDate(Date createdDate) {
|
||||||
|
result.setCreatedDate(createdDate);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SampleInheritedEntityBuilder message(String message) {
|
||||||
|
result.setMessage(message);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SampleInheritedEntity build() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndexQuery buildIndex() {
|
||||||
|
IndexQuery indexQuery = new IndexQuery();
|
||||||
|
indexQuery.setId(Objects.requireNonNull(result.getId()));
|
||||||
|
indexQuery.setObject(result);
|
||||||
|
return indexQuery;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Artur Konczak
|
||||||
|
* @author Mohsin Husen
|
||||||
|
*/
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Kevin Letur
|
||||||
|
*/
|
||||||
|
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,
|
||||||
|
orientation = GeoShapeField.Orientation.clockwise) private String shape2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by akonczak on 21/08/2016.
|
||||||
|
*/
|
||||||
|
@Document(indexName = "test-index-user-mapping-builder")
|
||||||
|
static class User {
|
||||||
|
@Nullable @Id private String id;
|
||||||
|
|
||||||
|
@Field(type = FieldType.Nested, ignoreFields = { "users" }) private Set<Group> groups = new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by akonczak on 21/08/2016.
|
||||||
|
*/
|
||||||
|
@Document(indexName = "test-index-group-mapping-builder")
|
||||||
|
static class Group {
|
||||||
|
|
||||||
|
@Nullable @Id String id;
|
||||||
|
|
||||||
|
@Field(type = FieldType.Nested, ignoreFields = { "groups" }) private Set<User> users = new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ValueObject {
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public ValueObject(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Document(indexName = "completion")
|
||||||
|
static class CompletionDocument {
|
||||||
|
@Id private String id;
|
||||||
|
|
||||||
|
@CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO,
|
||||||
|
path = "proppath") }) private Completion suggest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Document(indexName = "test-index-entity-with-seq-no-primary-term-mapping-builder")
|
||||||
|
static class EntityWithSeqNoPrimaryTerm {
|
||||||
|
|
||||||
|
@Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
static class RankFeatureEntity {
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
}
|
@ -17,11 +17,9 @@
|
|||||||
package org.springframework.data.elasticsearch.core.index;
|
package org.springframework.data.elasticsearch.core.index;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
|
||||||
import static org.skyscreamer.jsonassert.JSONAssert.*;
|
import static org.skyscreamer.jsonassert.JSONAssert.*;
|
||||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||||
import static org.springframework.data.elasticsearch.annotations.FieldType.Object;
|
import static org.springframework.data.elasticsearch.annotations.FieldType.Object;
|
||||||
import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@ -36,44 +34,27 @@ import java.lang.Integer;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.assertj.core.data.Percentage;
|
|
||||||
import org.elasticsearch.search.suggest.completion.context.ContextMapping;
|
import org.elasticsearch.search.suggest.completion.context.ContextMapping;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.annotation.Transient;
|
import org.springframework.data.annotation.Transient;
|
||||||
import org.springframework.data.elasticsearch.annotations.*;
|
import org.springframework.data.elasticsearch.annotations.*;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|
||||||
import org.springframework.data.elasticsearch.core.IndexOperations;
|
|
||||||
import org.springframework.data.elasticsearch.core.SearchHits;
|
|
||||||
import org.springframework.data.elasticsearch.core.completion.Completion;
|
import org.springframework.data.elasticsearch.core.completion.Completion;
|
||||||
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
|
||||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
|
||||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
|
||||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
|
||||||
import org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm;
|
import org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm;
|
||||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
|
||||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
|
||||||
import org.springframework.data.geo.Box;
|
import org.springframework.data.geo.Box;
|
||||||
import org.springframework.data.geo.Circle;
|
import org.springframework.data.geo.Circle;
|
||||||
import org.springframework.data.geo.Point;
|
import org.springframework.data.geo.Point;
|
||||||
import org.springframework.data.geo.Polygon;
|
import org.springframework.data.geo.Polygon;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stuart Stevenson
|
* @author Stuart Stevenson
|
||||||
@ -87,34 +68,7 @@ import org.springframework.test.context.ContextConfiguration;
|
|||||||
* @author Xiao Yu
|
* @author Xiao Yu
|
||||||
* @author Roman Puchkovskiy
|
* @author Roman Puchkovskiy
|
||||||
*/
|
*/
|
||||||
@SpringIntegrationTest
|
public class MappingBuilderUnitTests extends MappingContextBaseTests {
|
||||||
@ContextConfiguration(classes = { ElasticsearchRestTemplateConfiguration.class })
|
|
||||||
public class MappingBuilderTests extends MappingContextBaseTests {
|
|
||||||
|
|
||||||
@Autowired private ElasticsearchOperations operations;
|
|
||||||
private IndexOperations indexOperations;
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
@BeforeEach
|
|
||||||
public void deleteIndices() {
|
|
||||||
indexOperations = operations.indexOps(SimpleRecursiveEntity.class);
|
|
||||||
indexOperations.delete();
|
|
||||||
operations.indexOps(StockPrice.class).delete();
|
|
||||||
operations.indexOps(SampleInheritedEntity.class).delete();
|
|
||||||
operations.indexOps(User.class).delete();
|
|
||||||
operations.indexOps(Group.class).delete();
|
|
||||||
operations.indexOps(Book.class).delete();
|
|
||||||
operations.indexOps(NormalizerEntity.class).delete();
|
|
||||||
operations.indexOps(CopyToEntity.class).delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldNotFailOnCircularReference() {
|
|
||||||
|
|
||||||
operations.indexOps(SimpleRecursiveEntity.class).create();
|
|
||||||
indexOperations.putMapping(SimpleRecursiveEntity.class);
|
|
||||||
indexOperations.refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test // DATAES-568
|
@Test // DATAES-568
|
||||||
public void testInfiniteLoopAvoidance() throws JSONException {
|
public void testInfiniteLoopAvoidance() throws JSONException {
|
||||||
@ -140,37 +94,6 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
|||||||
assertEquals(expected, mapping, false);
|
assertEquals(expected, mapping, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-530
|
|
||||||
public void shouldAddStockPriceDocumentToIndex() {
|
|
||||||
|
|
||||||
// Given
|
|
||||||
IndexOperations indexOps = operations.indexOps(StockPrice.class);
|
|
||||||
|
|
||||||
// When
|
|
||||||
indexOps.create();
|
|
||||||
indexOps.putMapping(StockPrice.class);
|
|
||||||
String symbol = "AU";
|
|
||||||
double price = 2.34;
|
|
||||||
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);
|
|
||||||
operations.indexOps(StockPrice.class).refresh();
|
|
||||||
|
|
||||||
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
|
|
||||||
SearchHits<StockPrice> result = operations.search(searchQuery, StockPrice.class, index);
|
|
||||||
|
|
||||||
// Then
|
|
||||||
assertThat(result).hasSize(1);
|
|
||||||
StockPrice entry = result.getSearchHit(0).getContent();
|
|
||||||
assertThat(entry.getSymbol()).isEqualTo(symbol);
|
|
||||||
assertThat(entry.getPrice()).isCloseTo(BigDecimal.valueOf(price), Percentage.withPercentage(0.01));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test // DATAES-76
|
@Test // DATAES-76
|
||||||
public void shouldBuildMappingWithSuperclass() throws JSONException {
|
public void shouldBuildMappingWithSuperclass() throws JSONException {
|
||||||
|
|
||||||
@ -183,31 +106,35 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
|||||||
assertEquals(expected, mapping, false);
|
assertEquals(expected, mapping, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-76
|
@Test // DATAES-285
|
||||||
public void shouldAddSampleInheritedEntityDocumentToIndex() {
|
public void shouldMapBooks() throws JSONException {
|
||||||
// given
|
|
||||||
IndexCoordinates index = IndexCoordinates.of("test-index-sample-inherited-mapping-builder");
|
|
||||||
IndexOperations indexOps = operations.indexOps(index);
|
|
||||||
|
|
||||||
// when
|
String expected = "{\n" + //
|
||||||
indexOps.create();
|
" \"properties\": {\n" + //
|
||||||
indexOps.putMapping(SampleInheritedEntity.class);
|
" \"author\": {\n" + //
|
||||||
Date createdDate = new Date();
|
" \"type\": \"object\",\n" + //
|
||||||
String message = "msg";
|
" \"properties\": {}\n" + //
|
||||||
String id = "abc";
|
" },\n" + //
|
||||||
operations.index(new SampleInheritedEntityBuilder(id).createdDate(createdDate).message(message).buildIndex(),
|
" \"buckets\": {\n" + //
|
||||||
index);
|
" \"type\": \"nested\"\n" + //
|
||||||
operations.indexOps(SampleInheritedEntity.class).refresh();
|
" },\n" + //
|
||||||
|
" \"description\": {\n" + //
|
||||||
|
" \"type\": \"text\",\n" + //
|
||||||
|
" \"analyzer\": \"whitespace\",\n" + //
|
||||||
|
" \"fields\": {\n" + //
|
||||||
|
" \"prefix\": {\n" + //
|
||||||
|
" \"type\": \"text\",\n" + //
|
||||||
|
" \"analyzer\": \"stop\",\n" + //
|
||||||
|
" \"search_analyzer\": \"standard\"\n" + //
|
||||||
|
" }\n" + //
|
||||||
|
" }\n" + //
|
||||||
|
" }\n" + //
|
||||||
|
" }\n" + //
|
||||||
|
"}"; //
|
||||||
|
|
||||||
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
|
String mapping = getMappingBuilder().buildPropertyMapping(Book.class);
|
||||||
SearchHits<SampleInheritedEntity> result = operations.search(searchQuery, SampleInheritedEntity.class, index);
|
|
||||||
|
|
||||||
// then
|
assertEquals(expected, mapping, false);
|
||||||
assertThat(result).hasSize(1);
|
|
||||||
|
|
||||||
SampleInheritedEntity entry = result.getSearchHit(0).getContent();
|
|
||||||
assertThat(entry.getCreatedDate()).isEqualTo(createdDate);
|
|
||||||
assertThat(entry.getMessage()).isEqualTo(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-568, DATAES-929
|
@Test // DATAES-568, DATAES-929
|
||||||
@ -250,101 +177,6 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
|||||||
assertEquals(expected, mapping, false);
|
assertEquals(expected, mapping, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-260 - StackOverflow when two reverse relationship.
|
|
||||||
public void shouldHandleReverseRelationship() {
|
|
||||||
|
|
||||||
// given
|
|
||||||
IndexOperations indexOpsUser = operations.indexOps(User.class);
|
|
||||||
indexOpsUser.create();
|
|
||||||
indexOpsUser.putMapping(User.class);
|
|
||||||
|
|
||||||
IndexOperations indexOpsGroup = operations.indexOps(Group.class);
|
|
||||||
indexOpsGroup.create();
|
|
||||||
indexOpsGroup.putMapping(Group.class);
|
|
||||||
|
|
||||||
// when
|
|
||||||
|
|
||||||
// then
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test // DATAES-285
|
|
||||||
public void shouldMapBooks() {
|
|
||||||
|
|
||||||
// given
|
|
||||||
IndexOperations indexOps = operations.indexOps(Book.class);
|
|
||||||
indexOps.create();
|
|
||||||
indexOps.putMapping(Book.class);
|
|
||||||
|
|
||||||
// when
|
|
||||||
|
|
||||||
// then
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test // DATAES-420
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
||||||
public void shouldUseBothAnalyzer() {
|
|
||||||
|
|
||||||
// given
|
|
||||||
IndexOperations indexOps = this.operations.indexOps(Book.class);
|
|
||||||
indexOps.create();
|
|
||||||
indexOps.putMapping(Book.class);
|
|
||||||
|
|
||||||
// when
|
|
||||||
Map mapping = indexOps.getMapping();
|
|
||||||
Map descriptionMapping = (Map) ((Map) mapping.get("properties")).get("description");
|
|
||||||
Map prefixDescription = (Map) ((Map) descriptionMapping.get("fields")).get("prefix");
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(prefixDescription).hasSize(3);
|
|
||||||
assertThat(prefixDescription.get("type")).isEqualTo("text");
|
|
||||||
assertThat(prefixDescription.get("analyzer")).isEqualTo("stop");
|
|
||||||
assertThat(prefixDescription.get("search_analyzer")).isEqualTo("standard");
|
|
||||||
assertThat(descriptionMapping.get("type")).isEqualTo("text");
|
|
||||||
assertThat(descriptionMapping.get("analyzer")).isEqualTo("whitespace");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test // DATAES-492
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public void shouldUseKeywordNormalizer() {
|
|
||||||
|
|
||||||
// given
|
|
||||||
operations.createIndex(NormalizerEntity.class);
|
|
||||||
operations.putMapping(NormalizerEntity.class);
|
|
||||||
|
|
||||||
// when
|
|
||||||
Map mapping = operations.getMapping(NormalizerEntity.class);
|
|
||||||
Map properties = (Map) mapping.get("properties");
|
|
||||||
Map fieldName = (Map) properties.get("name");
|
|
||||||
Map fieldDescriptionLowerCase = (Map) ((Map) ((Map) properties.get("description")).get("fields")).get("lower_case");
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(fieldName.get("type")).isEqualTo("keyword");
|
|
||||||
assertThat(fieldName.get("normalizer")).isEqualTo("lower_case_normalizer");
|
|
||||||
assertThat(fieldDescriptionLowerCase.get("type")).isEqualTo("keyword");
|
|
||||||
assertThat(fieldDescriptionLowerCase.get("normalizer")).isEqualTo("lower_case_normalizer");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test // DATAES-503
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public void shouldUseCopyTo() {
|
|
||||||
|
|
||||||
// given
|
|
||||||
IndexOperations indexOps = operations.indexOps(CopyToEntity.class);
|
|
||||||
indexOps.create();
|
|
||||||
indexOps.putMapping(CopyToEntity.class);
|
|
||||||
|
|
||||||
// when
|
|
||||||
Map mapping = indexOps.getMapping();
|
|
||||||
Map properties = (Map) mapping.get("properties");
|
|
||||||
Map fieldFirstName = (Map) properties.get("firstName");
|
|
||||||
Map fieldLastName = (Map) properties.get("lastName");
|
|
||||||
|
|
||||||
// then
|
|
||||||
List<String> copyToValue = Collections.singletonList("name");
|
|
||||||
assertThat(fieldFirstName.get("copy_to")).isEqualTo(copyToValue);
|
|
||||||
assertThat(fieldLastName.get("copy_to")).isEqualTo(copyToValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test // DATAES-568
|
@Test // DATAES-568
|
||||||
public void shouldUseFieldNameOnId() throws JSONException {
|
public void shouldUseFieldNameOnId() throws JSONException {
|
||||||
|
|
||||||
@ -663,7 +495,6 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
|||||||
/**
|
/**
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
|
||||||
static class FieldNameEntity {
|
static class FieldNameEntity {
|
||||||
|
|
||||||
@Document(indexName = "fieldname-index")
|
@Document(indexName = "fieldname-index")
|
||||||
@ -849,40 +680,6 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Kevin Leturc
|
|
||||||
*/
|
|
||||||
static class SampleInheritedEntityBuilder {
|
|
||||||
|
|
||||||
private final SampleInheritedEntity result;
|
|
||||||
|
|
||||||
public SampleInheritedEntityBuilder(String id) {
|
|
||||||
result = new SampleInheritedEntity();
|
|
||||||
result.setId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SampleInheritedEntityBuilder createdDate(Date createdDate) {
|
|
||||||
result.setCreatedDate(createdDate);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SampleInheritedEntityBuilder message(String message) {
|
|
||||||
result.setMessage(message);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SampleInheritedEntity build() {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IndexQuery buildIndex() {
|
|
||||||
IndexQuery indexQuery = new IndexQuery();
|
|
||||||
indexQuery.setId(Objects.requireNonNull(result.getId()));
|
|
||||||
indexQuery.setObject(result);
|
|
||||||
return indexQuery;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
@ -940,7 +737,7 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
|||||||
|
|
||||||
@Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
@Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||||
|
|
||||||
@Nullable @Transient private SampleTransientEntity.NestedEntity nested;
|
@Nullable @Transient private NestedEntity nested;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@ -962,14 +759,14 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
|||||||
|
|
||||||
static class NestedEntity {
|
static class NestedEntity {
|
||||||
|
|
||||||
@Field private static SampleTransientEntity.NestedEntity someField = new SampleTransientEntity.NestedEntity();
|
@Field private static NestedEntity someField = new NestedEntity();
|
||||||
@Nullable @Field private Boolean something;
|
@Nullable @Field private Boolean something;
|
||||||
|
|
||||||
public SampleTransientEntity.NestedEntity getSomeField() {
|
public NestedEntity getSomeField() {
|
||||||
return someField;
|
return someField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSomeField(SampleTransientEntity.NestedEntity someField) {
|
public void setSomeField(NestedEntity someField) {
|
||||||
NestedEntity.someField = someField;
|
NestedEntity.someField = someField;
|
||||||
}
|
}
|
||||||
|
|
@ -55,8 +55,8 @@ public class ElasticsearchRestTemplateConfiguration extends AbstractElasticsearc
|
|||||||
}
|
}
|
||||||
|
|
||||||
return RestClients.create(configurationBuilder //
|
return RestClients.create(configurationBuilder //
|
||||||
.withConnectTimeout(Duration.ofSeconds(5)) //
|
.withConnectTimeout(Duration.ofSeconds(20)) //
|
||||||
.withSocketTimeout(Duration.ofSeconds(3)) //
|
.withSocketTimeout(Duration.ofSeconds(20)) //
|
||||||
.build()) //
|
.build()) //
|
||||||
.rest();
|
.rest();
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,5 +31,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@ExtendWith(SpringDataElasticsearchExtension.class)
|
@ExtendWith(SpringDataElasticsearchExtension.class)
|
||||||
|
@Tag(Tags.INTEGRATION_TEST)
|
||||||
public @interface IntegrationTest {
|
public @interface IntegrationTest {
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.junit.jupiter;
|
package org.springframework.data.elasticsearch.junit.jupiter;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.elasticsearch.client.ClientConfiguration;
|
import org.springframework.data.elasticsearch.client.ClientConfiguration;
|
||||||
@ -45,7 +47,9 @@ public class ReactiveElasticsearchRestTemplateConfiguration extends AbstractReac
|
|||||||
.usingSsl();
|
.usingSsl();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ReactiveRestClients.create(configurationBuilder.build());
|
return ReactiveRestClients.create(configurationBuilder //
|
||||||
|
.withConnectTimeout(Duration.ofSeconds(20)) //
|
||||||
|
.withSocketTimeout(Duration.ofSeconds(20)) //
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
@ -32,5 +33,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@ExtendWith(SpringDataElasticsearchExtension.class)
|
@ExtendWith(SpringDataElasticsearchExtension.class)
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
|
@Tag(Tags.INTEGRATION_TEST)
|
||||||
public @interface SpringIntegrationTest {
|
public @interface SpringIntegrationTest {
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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.junit.jupiter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
|
*/
|
||||||
|
public interface Tags {
|
||||||
|
String INTEGRATION_TEST = "integration-test";
|
||||||
|
}
|
@ -35,14 +35,13 @@ import org.junit.jupiter.api.AfterAll;
|
|||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||||
import org.springframework.data.elasticsearch.annotations.InnerField;
|
import org.springframework.data.elasticsearch.annotations.InnerField;
|
||||||
import org.springframework.data.elasticsearch.annotations.MultiField;
|
import org.springframework.data.elasticsearch.annotations.MultiField;
|
||||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringDataElasticsearchExtension;
|
import org.springframework.data.elasticsearch.junit.jupiter.IntegrationTest;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +50,7 @@ import org.springframework.lang.Nullable;
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@ExtendWith(SpringDataElasticsearchExtension.class)
|
@IntegrationTest
|
||||||
public class CdiRepositoryTests {
|
public class CdiRepositoryTests {
|
||||||
|
|
||||||
@Nullable private static CdiTestContainer cdiContainer;
|
@Nullable private static CdiTestContainer cdiContainer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user