1
0
mirror of synced 2026-07-07 10:40:02 +00:00

Compare commits

...

64 Commits

Author SHA1 Message Date
Spring Buildmaster eb4111d715 DATAES-173 - Release version 1.0.6.RELEASE (Dijkstra SR6). 2015-06-30 23:18:21 -07:00
Oliver Gierke 1a695c7c60 DATAES-173 - Prepare 1.0.6.RELEASE (Dijkstra SR6). 2015-07-01 08:04:28 +02:00
Oliver Gierke 0c4620cd5e DATAES-173 - Updated changelog. 2015-07-01 08:04:28 +02:00
Oliver Gierke 5da79b56aa DATAES-174 - Updated changelog. 2015-07-01 08:00:45 +02:00
Oliver Gierke d17b2d79d1 DATAES-175 - Updated changelog. 2015-06-30 14:24:08 +02:00
Oliver Gierke 49b5c8d7bf DATAES-168 - Updated changelog. 2015-06-30 14:24:01 +02:00
Oliver Gierke 06f73b910e DATAES-154 - Updated changelog. 2015-06-30 14:23:55 +02:00
Oliver Gierke d992709a0c DATAES-152 - Updated changelog. 2015-06-30 14:23:47 +02:00
Oliver Gierke d849704617 DATAES-146 - Updated changelog. 2015-06-30 14:23:12 +02:00
Oliver Gierke 4b02ca6c07 DATAES-145 - After release cleanups. 2015-01-27 18:29:24 +01:00
Spring Buildmaster dfe7f76910 DATAES-145 - Prepare next development iteration. 2015-01-27 06:51:48 -08:00
Spring Buildmaster 103e5b2889 DATAES-145 - Release version 1.0.5.RELEASE (Dijsktra SR5). 2015-01-27 06:51:46 -08:00
Oliver Gierke 7414d21613 DATAES-145 - Prepare 1.0.5.RELEASE (Dijkstra SR5). 2015-01-27 15:15:31 +01:00
Oliver Gierke 409a2acb5a DATAES-145 - Updated changelog. 2015-01-27 14:35:22 +01:00
Oliver Gierke b83bed4b7f DATAES-134 - Updated changelog. 2015-01-20 07:58:51 +01:00
Oliver Gierke 3b2d39a8f2 DATAES-133 - Updated changelog. 2015-01-20 07:58:43 +01:00
Oliver Gierke 8162a20da7 DATAES-128 - Updated changelog. 2015-01-20 07:58:32 +01:00
Oliver Gierke c189c1c8f2 DATAES-122 - After release cleanups. 2014-08-27 12:37:02 +02:00
Spring Buildmaster 7d8dabb806 DATAES-122 - Prepare next development iteration. 2014-08-27 03:29:45 -07:00
Spring Buildmaster 0ffd90552d DATAES-122 - Release version 1.0.4.RELEASE (Dijkstra SR4). 2014-08-27 03:29:43 -07:00
Oliver Gierke 914c2892f9 DATAES-122 - Prepare 1.0.4.RELEASE (Dijkstra SR4). 2014-08-27 11:28:27 +02:00
Oliver Gierke 11d91de0ab DATAES-122 - Updated changelog. 2014-08-27 11:28:18 +02:00
Oliver Gierke 4ff42f1b2f DATAES-119 - Updated changelog. 2014-08-27 07:36:40 +02:00
Oliver Gierke 99d4f4a619 DATAES-107 - After release cleanups. 2014-07-28 12:24:58 +02:00
Spring Buildmaster fe757560ed DATAES-107 - Prepare next development iteration. 2014-07-28 03:20:56 -07:00
Spring Buildmaster 6c79b5a6a3 DATAES-107 - Release version 1.0.2.RELEASE (Dijkstra SR2). 2014-07-28 03:20:54 -07:00
Oliver Gierke fff436a2af DATAES-107 - Prepare 1.0.2.RELEASE (Dijkstra SR2). 2014-07-28 10:20:04 +02:00
Oliver Gierke 8f01a48b52 DATAES-107 - Updated changelog. 2014-07-28 10:19:55 +02:00
Oliver Gierke 02e6aa44c2 DATAES-102 - Updated changelog. 2014-07-25 07:55:40 +02:00
Oliver Gierke 379900e035 DATAES-99 - After release cleanups. 2014-06-30 16:47:28 +02:00
Spring Buildmaster 6ba2ed9d0d DATAES-99 - Prepare next development iteration. 2014-06-30 07:07:18 -07:00
Spring Buildmaster d298bc727c DATAES-99 - Release version 1.0.1.RELEASE (Dijkstra SR1). 2014-06-30 07:07:15 -07:00
Oliver Gierke 179e626cb5 DATAES-99 - Prepare 1.0.1.RELEASE (Dijkstra SR1). 2014-06-30 16:00:55 +02:00
Oliver Gierke b7f2d4bcc7 DATAES-99 - Updated changelog. 2014-06-30 16:00:10 +02:00
Oliver Gierke 4aa6e7fc9b DATAES-90 - Prepare next development iteration. 2014-06-30 15:59:58 +02:00
Spring Buildmaster c1bffb0324 DATAES-90 - Release version 1.0.0.RELEASE. 2014-05-20 09:47:43 -07:00
Oliver Gierke 407768ac7f DATAES-90 - Prepare 1.0 GA.
Tweaked README.md. Replaced Docbook index.xml as it apparently used a different encoding scheme.
2014-05-20 17:04:45 +02:00
Oliver Gierke 8fbd00dfa7 DATAES-90 - Updated changelog. 2014-05-20 16:26:34 +02:00
Mohsin Husen 4fa8a31148 DATAES-87 - post release cleanups. 2014-05-03 10:52:13 +01:00
Oliver Gierke dbaabdeca0 DATAES-87 - After release cleanups. 2014-05-02 15:25:21 +02:00
Spring Buildmaster 0f4dc51ad9 DATAES-87 - Prepare next development iteration. 2014-05-02 05:29:55 -07:00
Spring Buildmaster 173a6cf326 DATAES-87 - Release 1.0.0.RC1. 2014-05-02 05:29:53 -07:00
Oliver Gierke ea6de5aab2 DATAES-87 - Switched to tabs in pom.xml. 2014-05-02 14:27:52 +02:00
Oliver Gierke 4ff1ff86f2 DATAES-87 - Prepare 1.0.0.RC1.
Upgraded to Spring Data Parent 1.4.0.RC1 and Spring Data Commons 1.8.0.RC1. Switched to milestone repository.
2014-05-02 14:21:01 +02:00
Oliver Gierke fdc8bbe0a2 DATAES-87 - Updated changelog. 2014-05-02 14:16:56 +02:00
Artur Konczak 7bb409887e DATAES-81 - extended RangeFacetRequest to support string ranges 2014-05-01 15:16:40 +01:00
Mohsin Husen 230c041d83 DATAES-88 - add method createIndex(Class<T> clazz, Object settings) 2014-05-01 11:46:20 +01:00
Oliver Gierke 3261af3f5a DATAES-87 - Polished changelog.
Introduced headline to make sure we can automate the changelog creation going forward. Made sure formatting is consistent.
2014-04-30 17:31:40 +02:00
Mohsin Husen 9ce87f147a DATAES-86 - Add dynamic mapping(json) using @Mapping annotation 2014-04-30 11:48:00 +01:00
Mohsin Husen 8c63f3ee22 DATAES-82 - findAll(Iterable<ID> ids) does not work with Collections
terms query does not support iterable, converted Iterable to Collection
2014-04-29 12:01:47 +01:00
Mohsin Husen ad0409c7ae DATAES-63 - Ability to add mapping using arbitrary JSON and XContentBuilder using ElasticsearchTemplate 2014-04-25 16:00:56 +01:00
Mohsin Husen 6b6f3beabe DATAES-85 - Add support to get elasticsearch mappings 2014-04-24 15:19:00 +01:00
Mohsin Husen 5ca0ed7ff1 DATAES-84 - Add field criteria with searchQuery not supported in scan and scroll
- added support for fields in scan and scroll
- fixed build failure, separated aliasTests
2014-04-23 12:29:32 +01:00
Mohsin Husen 1b18da2e21 DATAES-83 - Upgrade to elasticsearch 1.1.1 2014-04-21 17:45:01 +01:00
Mohsin Husen 55219c947e DATAES-77 - Search across different indices
applied Spring Data coding/formatting rules
2014-04-21 17:26:08 +01:00
abdul d24a92547f DATAES-77 - Search across different indices
Add test to demonstrate searching into heterogeneous indexes and building entities of different types. In a nutshall, the responsiblity lies with the client, spring data elasticsearch cannot and should not try to discover entity types, as that would leading building an object composition logic which is not the core area of this library.

With this test, we demonstrate the usage of SearchResultMapper to compose an aggregator object that holds properties from two dfferent entities, The Aggregator is declared as a document but is not indexes (This is not ideal) and we don't recommend to declare @Documents that are not indexed. Please use this as just a pointer to implement SearchResultMapper, this demostartion is not meant to be duplicated in your production systems. There are better ways to compose hetro objects from multi index searches.
2014-04-17 09:26:11 +01:00
abdul 09e3e94b3b DATAES-77 - Search across different indices
Add a test to demonstrate searching across multiple indices.
2014-04-16 13:24:56 +01:00
Mohsin Husen 0eb230cb1f DATAES-66 - Add Ip support to FieldType
renamed from DynamicMappingAndSettingTests to LogEntityTests
2014-04-09 16:00:39 +01:00
Mohsin Husen 0307803316 DATAES-66 - Add Ip support to FieldType
added test cases for FieldType.Ip
2014-04-09 15:56:35 +01:00
Aggelos Karalias cbe549694e DATAES-66 - Add Ip support to FieldType
This is as trivial as adding a value to the FieldType enum. It doesn't have any
extra properties following the IP type so the
MappingBuilder.addSingleFieldMapping will do the job.
2014-04-09 10:42:21 +01:00
Mohsin Husen 1eafa61cc9 DATAES-80 - Update github url in pom.xml 2014-04-07 14:00:23 +01:00
Mohsin Husen 9e97dec225 DATAES-70 - Alias creation with routing not supported
added routing parameters
2014-04-03 16:49:50 +01:00
Mohsin Husen 3453f30a26 DATAES-78 - Typo 2014-03-31 17:10:21 +01:00
Spring Buildmaster 645e2b77c3 DATAES-78 - Prepare next development iteration. 2014-03-31 17:48:59 +02:00
36 changed files with 1714 additions and 596 deletions
+12 -21
View File
@@ -10,17 +10,18 @@ The Spring Data Elasticsearch project provides integration with the [elasticsear
Guide
------------
* [Reference Documentation](http://docs.spring.io/spring-data/elasticsearch/docs/1.0.0.M2/reference/html/)
* [PDF Documentation](http://docs.spring.io/spring-data/elasticsearch/docs/1.0.0.M2/reference/pdf/spring-data-elasticsearch-reference.pdf)
* [API Documentation](http://docs.spring.io/spring-data/elasticsearch/docs/1.0.0.M2/api/)
* [Reference Documentation](http://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/)
* [PDF Documentation](http://docs.spring.io/spring-data/elasticsearch/docs/current/reference/pdf/spring-data-elasticsearch-reference.pdf)
* [API Documentation](http://docs.spring.io/spring-data/elasticsearch/docs/current/api/)
* [Spring Data Project](http://project.spring.io/spring-data)
* [Sample Test Application](https://github.com/BioMedCentralLtd/spring-data-elasticsearch-sample-application)
* for more detailed questions, use the [forum](http://forum.springsource.org/forumdisplay.php?f=80).
* [Spring Data Elasticsearch Google Group](https://groups.google.com/d/forum/spring-data-elasticsearch-devs)
* For more detailed questions, use the [forum](http://forum.springsource.org/forumdisplay.php?f=80).
Quick Start
-----------
Wiki page for [Getting Started] (https://github.com/spring-projects/spring-data-elasticsearch/wiki/How-to-start-with-spring-data-elasticsearch)
Wiki page for [Getting Started](https://github.com/spring-projects/spring-data-elasticsearch/wiki/How-to-start-with-spring-data-elasticsearch)
### Maven configuration
@@ -30,14 +31,8 @@ Add the Maven dependency:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>1.1.0.M1</version>
<version>1.0.0.RELEASE</version>
</dependency>
<repository>
<id>spring-libs-milestone</id>
<name>Spring Milestone Repository</name>
<url>http://repo.spring.io/libs-milestone</url>
</repository>
```
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare
@@ -192,8 +187,8 @@ Using Node Client
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<elasticsearch:node-client id="client" local="true"/>
@@ -211,8 +206,8 @@ Using Transport Client
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<elasticsearch:repositories base-package="com.xyz.acme"/>
@@ -244,8 +239,4 @@ Before we accept a non-trivial patch or pull request we will need you to sign th
Code formatting for [Eclipse and Intellij](https://github.com/spring-projects/spring-data-build/tree/master/etc/ide)
[More information about contributing to Spring Data](https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.md)
### Contact Details
* [Spring Data Elasticsearch Support] (https://groups.google.com/d/forum/spring-data-elasticsearch-devs)
[More information about contributing to Spring Data](https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.md)
+178 -178
View File
@@ -1,178 +1,178 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>1.0.0.M2</version>
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>1.4.0.M1</version>
<relativePath>../spring-data-build/parent/pom.xml</relativePath>
</parent>
<name>Spring Data Elasticsearch</name>
<description>Spring Data Implementation for Elasticsearch</description>
<url>https://github.com/SpringSource/spring-data-elasticsearch</url>
<properties>
<dist.key>DATAES</dist.key>
<commonscollections>3.2.1</commonscollections>
<commonslang>2.6</commonslang>
<elasticsearch>1.1.0</elasticsearch>
<springdata.commons>1.8.0.M1</springdata.commons>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<!-- SPRING DATA -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>${springdata.commons}</version>
</dependency>
<!-- APACHE -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commonslang}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commonscollections}</version>
</dependency>
<!-- JODA Time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime}</version>
</dependency>
<!-- Elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch}</version>
</dependency>
<!-- Jackson JSON Mapper -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson}</version>
</dependency>
<!-- CDI -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>${cdi}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans.test</groupId>
<artifactId>cditest-owb</artifactId>
<version>${webbeans}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<developers>
<developer>
<id>biomedcentral</id>
<name>BioMed Central Development Team</name>
<timezone>+0</timezone>
</developer>
</developers>
<repositories>
<repository>
<id>spring-libs-milestone</id>
<url>http://repo.spring.io/libs-milestone</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-plugins-release</id>
<url>http://repo.spring.io/plugins-release</url>
</pluginRepository>
</pluginRepositories>
<scm>
<url>https://github.com/SpringSource/spring-data-elasticsearch</url>
<connection>scm:git:git://github.com/SpringSource/spring-data-elasticsearch.git</connection>
<developerConnection>scm:git:ssh://git@github.com:SpringSource/spring-data-elasticsearch.git
</developerConnection>
</scm>
<ciManagement>
<system>Bamboo</system>
<url>http://build.springsource.org/browse/SPRINGDATAES</url>
</ciManagement>
<issueManagement>
<system>JIRA</system>
<url>https://jira.springsource.org/browse/DATAES</url>
</issueManagement>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>1.0.6.RELEASE</version>
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>1.4.6.RELEASE</version>
<relativePath>../spring-data-build/parent/pom.xml</relativePath>
</parent>
<name>Spring Data Elasticsearch</name>
<description>Spring Data Implementation for Elasticsearch</description>
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
<properties>
<dist.key>DATAES</dist.key>
<commonscollections>3.2.1</commonscollections>
<commonslang>2.6</commonslang>
<elasticsearch>1.1.1</elasticsearch>
<springdata.commons>1.8.6.RELEASE</springdata.commons>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<!-- SPRING DATA -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>${springdata.commons}</version>
</dependency>
<!-- APACHE -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commonslang}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commonscollections}</version>
</dependency>
<!-- JODA Time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime}</version>
</dependency>
<!-- Elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch}</version>
</dependency>
<!-- Jackson JSON Mapper -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson}</version>
</dependency>
<!-- CDI -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>${cdi}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans.test</groupId>
<artifactId>cditest-owb</artifactId>
<version>${webbeans}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<developers>
<developer>
<id>biomedcentral</id>
<name>BioMed Central Development Team</name>
<timezone>+0</timezone>
</developer>
</developers>
<repositories>
<repository>
<id>spring-libs-release</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-plugins-release</id>
<url>http://repo.spring.io/plugins-release</url>
</pluginRepository>
</pluginRepositories>
<scm>
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
<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>
<ciManagement>
<system>Bamboo</system>
<url>http://build.springsource.org/browse/SPRINGDATAES</url>
</ciManagement>
<issueManagement>
<system>JIRA</system>
<url>https://jira.springsource.org/browse/DATAES</url>
</issueManagement>
</project>
+59 -62
View File
@@ -1,62 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<book xmlns:xi="http://www.w3.org/2001/XInclude">
<bookinfo>
<title>Spring Data Elasticsearch</title>
<authorgroup>
<author>
<firstname>BioMed Central</firstname>
<surname>Development Team</surname>
</author>
</authorgroup>
<legalnotice>
<para>
Copies of this document may be made for your own use and for
distribution to others, provided that you do not
charge any fee for
such copies and further provided that each copy
contains this
Copyright Notice, whether
distributed in print or electronically.
</para>
</legalnotice>
<copyright>
<year>2013-2014</year>
<holder>The original author(s)</holder>
</copyright>
</bookinfo>
<toc/>
<xi:include href="preface.xml"/>
<part id="reference">
<title>Reference Documentation</title>
<xi:include
href="https://raw.github.com/SpringSource/spring-data-commons/1.8.0.M1/src/docbkx/repositories.xml">
<xi:fallback
href="../../../spring-data-commons/src/docbkx/repositories.xml"/>
</xi:include>
<xi:include href="reference/data-elasticsearch.xml"/>
<xi:include href="reference/elasticsearch-misc.xml"/>
</part>
<part id="appendix">
<title>Appendix</title>
<xi:include
href="https://raw.github.com/SpringSource/spring-data-commons/1.8.0.M1/src/docbkx/repository-namespace-reference.xml">
<xi:fallback
href="../../../spring-data-commons/src/docbkx/repository-namespace-reference.xml"/>
</xi:include>
<xi:include
href="https://raw.github.com/SpringSource/spring-data-commons/1.8.0.M1/src/docbkx/repository-query-keywords-reference.xml">
<xi:fallback
href="../../../spring-data-commons/src/docbkx/repository-query-keywords-reference.xml"/>
</xi:include>
</part>
</book>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<book xmlns:xi="http://www.w3.org/2001/XInclude">
<bookinfo>
<title>Spring Data Elasticsearch</title>
<authorgroup>
<author>
<firstname>BioMed Central</firstname>
<surname>Development Team</surname>
</author>
</authorgroup>
<legalnotice>
<para>
Copies of this document may be made for your own use and for
distribution to others, provided that you do not
charge any fee for
such copies and further provided that each copy
contains this
Copyright Notice, whether
distributed in print or electronically.
</para>
</legalnotice>
<copyright>
<year>2013-2014</year>
<holder>The original author(s)</holder>
</copyright>
</bookinfo>
<toc/>
<xi:include href="preface.xml"/>
<part id="reference">
<title>Reference Documentation</title>
<xi:include href="https://raw.github.com/SpringSource/spring-data-commons/1.8.2.RELEASE/src/docbkx/repositories.xml">
<xi:fallback
href="../../../spring-data-commons/src/docbkx/repositories.xml"/>
</xi:include>
<xi:include href="reference/data-elasticsearch.xml"/>
<xi:include href="reference/elasticsearch-misc.xml"/>
</part>
<part id="appendix">
<title>Appendix</title>
<xi:include href="https://raw.github.com/SpringSource/spring-data-commons/1.8.2.RELEASE/src/docbkx/repository-namespace-reference.xml">
<xi:fallback
href="../../../spring-data-commons/src/docbkx/repository-namespace-reference.xml"/>
</xi:include>
<xi:include href="https://raw.github.com/SpringSource/spring-data-commons/1.8.2.RELEASE/src/docbkx/repository-query-keywords-reference.xml">
<xi:fallback
href="../../../spring-data-commons/src/docbkx/repository-query-keywords-reference.xml"/>
</xi:include>
</part>
</book>
@@ -21,5 +21,5 @@ package org.springframework.data.elasticsearch.annotations;
* @author Artur Konczak
*/
public enum FieldType {
String, Integer, Long, Date, Float, Double, Boolean, Object, Auto, Nested
String, Integer, Long, Date, Float, Double, Boolean, Object, Auto, Nested, Ip
}
@@ -0,0 +1,34 @@
/*
* Copyright 2014 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
*
* http://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.annotations;
import java.lang.annotation.*;
import org.springframework.data.annotation.Persistent;
/**
* Elasticsearch Mapping
*
* @author Mohsin Husen
*/
@Persistent
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface Mapping {
String mappingPath() default "";
}
@@ -33,7 +33,7 @@ public class DefaultEntityMapper implements EntityMapper {
public DefaultEntityMapper() {
objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
}
@Override
@@ -61,6 +61,14 @@ public interface ElasticsearchOperations {
*/
boolean createIndex(String indexName, Object settings);
/**
* Create an index for given class and Settings
*
* @param clazz
* @param settings
*/
<T> boolean createIndex(Class<T> clazz, Object settings);
/**
* Create mapping for a class
*
@@ -69,6 +77,40 @@ public interface ElasticsearchOperations {
*/
<T> boolean putMapping(Class<T> clazz);
/**
* Create mapping for a given indexName and type
*
* @param indexName
* @param type
* @param mappings
*/
boolean putMapping(String indexName, String type, Object mappings);
/**
* Create mapping for a class
*
* @param clazz
* @param mappings
*/
<T> boolean putMapping(Class<T> clazz, Object mappings);
/**
* Get mapping for a class
*
* @param clazz
* @param <T>
*/
<T> Map getMapping(Class<T> clazz);
/**
* Get mapping for a given indexName and type
*
* @param indexName
* @param type
*/
Map getMapping(String indexName, String type);
/**
* Get settings for a given indexName
*
@@ -19,6 +19,7 @@ import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
import static org.apache.commons.lang.StringUtils.*;
import static org.elasticsearch.action.search.SearchType.*;
import static org.elasticsearch.client.Requests.*;
import static org.elasticsearch.cluster.metadata.AliasAction.Type.*;
import static org.elasticsearch.common.collect.Sets.*;
import static org.elasticsearch.index.VersionType.*;
import static org.springframework.data.elasticsearch.core.MappingBuilder.*;
@@ -31,10 +32,10 @@ import java.util.*;
import org.apache.commons.collections.CollectionUtils;
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.mapping.delete.DeleteMappingRequest;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder;
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
import org.elasticsearch.action.bulk.BulkItemResponse;
@@ -53,6 +54,7 @@ import org.elasticsearch.action.update.UpdateRequestBuilder;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.metadata.AliasAction;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.collect.MapBuilder;
@@ -73,6 +75,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.ElasticsearchException;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Mapping;
import org.springframework.data.elasticsearch.annotations.Setting;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
@@ -136,17 +139,66 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
@Override
public <T> boolean putMapping(Class<T> clazz) {
if (clazz.isAnnotationPresent(Mapping.class)) {
String mappingPath = clazz.getAnnotation(Mapping.class).mappingPath();
if (isNotBlank(mappingPath)) {
String mappings = readFileFromClasspath(mappingPath);
if (isNotBlank(mappings)) {
return putMapping(clazz, mappings);
}
} else {
logger.info("mappingPath in @Mapping has to be defined. Building mappings using @Field");
}
}
ElasticsearchPersistentEntity<T> persistentEntity = getPersistentEntityFor(clazz);
PutMappingRequestBuilder requestBuilder = client.admin().indices()
.preparePutMapping(persistentEntity.getIndexName()).setType(persistentEntity.getIndexType());
XContentBuilder xContentBuilder = null;
try {
XContentBuilder xContentBuilder = buildMapping(clazz, persistentEntity.getIndexType(), persistentEntity
xContentBuilder = buildMapping(clazz, persistentEntity.getIndexType(), persistentEntity
.getIdProperty().getFieldName(), persistentEntity.getParentType());
return requestBuilder.setSource(xContentBuilder).execute().actionGet().isAcknowledged();
} catch (Exception e) {
throw new ElasticsearchException("Failed to build mapping for " + clazz.getSimpleName(), e);
}
return putMapping(clazz, xContentBuilder);
}
@Override
public <T> boolean putMapping(Class<T> clazz, Object mapping) {
return putMapping(getPersistentEntityFor(clazz).getIndexName(), getPersistentEntityFor(clazz).getIndexType(), mapping);
}
@Override
public boolean putMapping(String indexName, String type, Object mapping) {
Assert.notNull(indexName, "No index defined for putMapping()");
Assert.notNull(type, "No type defined for putMapping()");
PutMappingRequestBuilder requestBuilder = client.admin().indices()
.preparePutMapping(indexName).setType(type);
if (mapping instanceof String) {
requestBuilder.setSource(String.valueOf(mapping));
} else if (mapping instanceof Map) {
requestBuilder.setSource((Map) mapping);
} else if (mapping instanceof XContentBuilder) {
requestBuilder.setSource((XContentBuilder) mapping);
}
return requestBuilder.execute().actionGet().isAcknowledged();
}
@Override
public Map getMapping(String indexName, String type) {
Assert.notNull(indexName, "No index defined for putMapping()");
Assert.notNull(type, "No type defined for putMapping()");
Map mappings = null;
try {
mappings = client.admin().indices().getMappings(new GetMappingsRequest().indices(indexName).types(type))
.actionGet().getMappings().get(indexName).get(type).getSourceAsMap();
} catch (Exception e) {
throw new ElasticsearchException("Error while getting mapping for indexName : " + indexName + " type : " + type + " " + e.getMessage());
}
return mappings;
}
@Override
public <T> Map getMapping(Class<T> clazz) {
return getMapping(getPersistentEntityFor(clazz).getIndexName(), getPersistentEntityFor(clazz).getIndexType());
}
@Override
@@ -343,7 +395,6 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
return updateRequestBuilder.execute().actionGet();
}
@Override
public void bulkIndex(List<IndexQuery> queries) {
BulkRequestBuilder bulkRequest = client.prepareBulk();
@@ -443,6 +494,10 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
requestBuilder.setPostFilter(searchQuery.getFilter());
}
if(isNotEmpty(searchQuery.getFields())) {
requestBuilder.addFields(toArray(searchQuery.getFields()));
}
if (noFields) {
requestBuilder.setNoFields();
}
@@ -561,11 +616,11 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
}
private <T> boolean createIndexWithSettings(Class<T> clazz) {
if(clazz.isAnnotationPresent(Setting.class)) {
if (clazz.isAnnotationPresent(Setting.class)) {
String settingPath = clazz.getAnnotation(Setting.class).settingPath();
if(isNotBlank(settingPath)) {
if (isNotBlank(settingPath)) {
String settings = readFileFromClasspath(settingPath);
if(isNotBlank(settings)) {
if (isNotBlank(settings)) {
return createIndex(getPersistentEntityFor(clazz).getIndexName(), settings);
}
} else {
@@ -575,7 +630,6 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
return createIndex(getPersistentEntityFor(clazz).getIndexName(), getDefaultSettings(getPersistentEntityFor(clazz)));
}
@Override
public boolean createIndex(String indexName, Object settings) {
CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
@@ -589,6 +643,11 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
return createIndexRequestBuilder.execute().actionGet().isAcknowledged();
}
@Override
public <T> boolean createIndex(Class<T> clazz, Object settings) {
return createIndex(getPersistentEntityFor(clazz).getIndexName(), settings);
}
private <T> Map getDefaultSettings(ElasticsearchPersistentEntity<T> persistentEntity) {
return new MapBuilder<String, String>().put("index.number_of_shards", String.valueOf(persistentEntity.getShards()))
.put("index.number_of_replicas", String.valueOf(persistentEntity.getReplicas()))
@@ -706,15 +765,19 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
public Boolean addAlias(AliasQuery query) {
Assert.notNull(query.getIndexName(), "No index defined for Alias");
Assert.notNull(query.getAliasName(), "No alias defined");
IndicesAliasesRequestBuilder indicesAliasesRequestBuilder = null;
AliasAction aliasAction = new AliasAction(ADD, query.getIndexName(), query.getAliasName());
if (query.getFilterBuilder() != null) {
indicesAliasesRequestBuilder = client.admin().indices().prepareAliases().addAlias(query.getIndexName(), query.getAliasName(), query.getFilterBuilder());
aliasAction.filter(query.getFilterBuilder());
} else if (query.getFilter() != null) {
indicesAliasesRequestBuilder = client.admin().indices().prepareAliases().addAlias(query.getIndexName(), query.getAliasName(), query.getFilter());
} else {
indicesAliasesRequestBuilder = client.admin().indices().prepareAliases().addAlias(query.getIndexName(), query.getAliasName());
aliasAction.filter(query.getFilter());
} else if (isNotBlank(query.getRouting())) {
aliasAction.routing(query.getRouting());
} else if (isNotBlank(query.getSearchRouting())) {
aliasAction.searchRouting(query.getSearchRouting());
} else if (isNotBlank(query.getIndexRouting())) {
aliasAction.indexRouting(query.getIndexRouting());
}
return indicesAliasesRequestBuilder.execute().actionGet().isAcknowledged();
return client.admin().indices().prepareAliases().addAliasAction(aliasAction).execute().actionGet().isAcknowledged();
}
@Override
@@ -29,6 +29,7 @@ import org.springframework.util.Assert;
* Range facet for numeric fields
*
* @author Artur Konczak
* @author Akos Bordas
*/
public class RangeFacetRequest extends AbstractFacetRequest {
@@ -36,8 +37,7 @@ public class RangeFacetRequest extends AbstractFacetRequest {
private String keyField;
private String valueField;
private List<Double> from = new ArrayList<Double>();
private List<Double> to = new ArrayList<Double>();
private List<Entry> entries = new ArrayList<Entry>();
public RangeFacetRequest(String name) {
super(name);
@@ -53,17 +53,19 @@ public class RangeFacetRequest extends AbstractFacetRequest {
}
public void range(Double from, Double to) {
if (from == null) {
this.from.add(Double.NEGATIVE_INFINITY);
} else {
this.from.add(from);
}
entries.add(new DoubleEntry(from, to));
}
if (to == null) {
this.to.add(Double.POSITIVE_INFINITY);
} else {
this.to.add(to);
}
public void range(String from, String to) {
entries.add(new StringEntry(from, to));
}
public void addRange(Double from, Double to) {
entries.add(new DoubleEntry(from, to));
}
public void addRange(String from, String to) {
entries.add(new StringEntry(from, to));
}
@Override
@@ -77,11 +79,54 @@ public class RangeFacetRequest extends AbstractFacetRequest {
} else {
builder.field(field);
}
Assert.notEmpty(from, "Please select at last one range");
Assert.notEmpty(to, "Please select at last one range");
for (int i = 0; i < from.size(); i++) {
builder.addRange(from.get(i), to.get(i));
for (Entry entry : entries) {
if (entry instanceof DoubleEntry) {
DoubleEntry doubleEntry = (DoubleEntry) entry;
builder.addRange(validateValue(doubleEntry.getFrom(), Double.NEGATIVE_INFINITY), validateValue(doubleEntry.getTo(), Double.POSITIVE_INFINITY));
} else {
StringEntry stringEntry = (StringEntry) entry;
builder.addRange(stringEntry.getFrom(), stringEntry.getTo());
}
}
return builder;
}
private double validateValue(Double value, double defaultValue) {
return value == null ? defaultValue : value;
}
static class DoubleEntry extends Entry<Double> {
DoubleEntry(Double from, Double to) {
super(from, to);
}
}
static class StringEntry extends Entry<String> {
StringEntry(String from, String to) {
super(from, to);
}
}
static class Entry<T> {
T from;
T to;
Entry(T from, T to) {
this.from = from;
this.to = to;
}
public T getFrom() {
return from;
}
public T getTo() {
return to;
}
}
}
@@ -46,6 +46,11 @@ public class RangeFacetRequestBuilder {
return this;
}
public RangeFacetRequestBuilder range(String from, String to) {
result.range(from, to);
return this;
}
public RangeFacetRequestBuilder from(double from) {
result.range(from, null);
return this;
@@ -56,6 +61,16 @@ public class RangeFacetRequestBuilder {
return this;
}
public RangeFacetRequestBuilder from(String from) {
result.range(from, null);
return this;
}
public RangeFacetRequestBuilder to(String to) {
result.range(null, to);
return this;
}
public RangeFacetRequestBuilder applyQueryFilter() {
result.setApplyQueryFilter(true);
return this;
@@ -68,7 +68,7 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
this.refreshInterval = typeInformation.getType().getAnnotation(Document.class).refreshInterval();
this.indexStoreType = typeInformation.getType().getAnnotation(Document.class).indexStoreType();
}
if(clazz.isAnnotationPresent(Setting.class)) {
if (clazz.isAnnotationPresent(Setting.class)) {
this.settingPath = typeInformation.getType().getAnnotation(Setting.class).settingPath();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@@ -28,6 +28,9 @@ public class AliasBuilder {
private String aliasName;
private FilterBuilder filterBuilder;
private Map<String, Object> filter;
private String searchRouting;
private String indexRouting;
private String routing;
public AliasBuilder withIndexName(String indexName) {
this.indexName = indexName;
@@ -49,12 +52,30 @@ public class AliasBuilder {
return this;
}
public AliasBuilder withSearchRouting(String searchRouting) {
this.searchRouting = searchRouting;
return this;
}
public AliasBuilder withIndexRouting(String indexRouting) {
this.indexRouting = indexRouting;
return this;
}
public AliasBuilder withRouting(String routing) {
this.routing = routing;
return this;
}
public AliasQuery build() {
AliasQuery aliasQuery = new AliasQuery();
aliasQuery.setIndexName(indexName);
aliasQuery.setAliasName(aliasName);
aliasQuery.setFilterBuilder(filterBuilder);
aliasQuery.setFilter(filter);
aliasQuery.setSearchRouting(searchRouting);
aliasQuery.setIndexRouting(indexRouting);
aliasQuery.setRouting(routing);
return aliasQuery;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@@ -30,6 +30,9 @@ public class AliasQuery {
private String aliasName;
private FilterBuilder filterBuilder;
private Map<String, Object> filter;
private String searchRouting;
private String indexRouting;
private String routing;
public String getIndexName() {
return indexName;
@@ -62,4 +65,28 @@ public class AliasQuery {
public void setFilter(Map<String, Object> filter) {
this.filter = filter;
}
public String getSearchRouting() {
return searchRouting;
}
public void setSearchRouting(String searchRouting) {
this.searchRouting = searchRouting;
}
public String getIndexRouting() {
return indexRouting;
}
public void setIndexRouting(String indexRouting) {
this.indexRouting = indexRouting;
}
public String getRouting() {
return routing;
}
public void setRouting(String routing) {
this.routing = routing;
}
}
@@ -26,6 +26,7 @@ import java.util.Collections;
import java.util.List;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.index.query.QueryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -118,7 +119,9 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
@Override
public Iterable<T> findAll(Iterable<ID> ids) {
SearchQuery query = new NativeSearchQueryBuilder().withQuery(inQuery(entityInformation.getIdAttribute(), ids))
Assert.notNull(ids, "ids can't be null.");
SearchQuery query = new NativeSearchQueryBuilder()
.withQuery(inQuery(entityInformation.getIdAttribute(), Lists.newArrayList(ids)))
.build();
return elasticsearchOperations.queryForPage(query, getEntityClass());
}
+213 -86
View File
@@ -1,95 +1,222 @@
Release Notes - Spring Data Elasticsearch - Version 1.0 M1 (2014-02-07)
-----------------------------------------------------------------------
** Bug
* [DATAES-9] - multiple elasticsearch cluster nodes not getting parsed if using property file
Spring Data Elasticsearch Changelog
===================================
** Improvement
* [DATAES-7] - Migrate to the latest version of elasticsearch 0.90.0
* [DATAES-11] - Missing core types in org.springframework.data.elasticsearch.annotations.FieldType
* [DATAES-15] - Upgrade to latest version of elasticsearch( 0.90.2 )
* [DATAES-19] - Delete specific type in an index, Type exists check
* [DATAES-22] - Add support for TransportClient additional parameters such as client.transport.ignore_cluster_name, client.transport.ping_timeout, client.transport.nodes_sampler_interval
Changes in version 1.0.6.RELEASE (2015-07-01)
---------------------------------------------
* DATAES-173 - Release 1.0.6 (Dijkstra).
** New Feature
* [DATAES-8] - Add support for Index level configuration
* [DATAES-17] - Add support to retrieve highlighted text in search result
** Task
* [DATAES-1] - Migrate sources to SpringSource GitHub repository
* [DATAES-3] - Move to Spring Data build system
* [DATAES-4] - Initial round of JavaDoc polish
* [DATAES-5] - Add Apache license headers where necessary
* [DATAES-6] - Add ability to let NodeClient clean up working directory
* [DATAES-45] - Release 1.0 M1.
Changes in version 1.1.3.RELEASE (2015-07-01)
---------------------------------------------
* DATAES-174 - Release 1.1.3 (Evans).
Issues maintaine in GitHub tracker:
- #42 - org.springframework.data.elasticsearch.client.NodeClientFactoryBean' is not a valid value for 'anyURI'
- #40 - how to create index for json objects?
- #38 - Configure with native Client with embedded elasticsearch
- #37 - embedded elasticsearch client - how to recover data after process is restarted?
- #36 - FieldType.Date annotation
- #35 - @Transient property still inserted into elastic
- #33 - timestamp mapping
- #32 - BigDecimal @Field(type = FieldType.Double)
- #31 - DATAES-33: Mapping of parent-child relationships
- #29 - Added DefaultMapper support to map only partial fields from result instead of whole source field.
- #28 - Documentation (README.md) for Geo Location / Filter Feature
- #27 - Adding support for letting Elasticsearch generate Id for document
- #25 - Aliases
- #24 - DATAES-31 Adding ability to use ES Java API setSource directly
- #22 - spring-elasticsearch-1.0.xsd not found on www.springframework.com
- #21 - Autogenerated elastic search id isn't returned
- #20 - Exception while using CustomRepository
- #19 - Compilation issue with 0.90.5. (ElasticsearchTemplate.refresh API)
- #18 - problem with ES 0.9.5
- #17 - FacetResult extension is not possible
- #16 - Configuration of ObjectMapper in the ElasticsearchTemplate
- #15 - Added support for @Transient annotation to skip fields from mapping
- #14 - added format and pattern support for date fieldtype + fixed nullpointer...
- #12 - Where is the maven repository for this artifact?
- #11 - Build fails
- #10 - Elasticsearch + elasticsearch-river-rabbitmq
- #9 - MappingBuilder circular reference issue
- #8 - java.lang.NoSuchMethodError: org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty.isVersionProperty()Z
- #7 - Missing core types in org.springframework.data.elasticsearch.annotations.FieldType
- #6 - spirng-data-elasticsearch with elasticsearch-river-mongodb
Changes in version 1.2.1.RELEASE (2015-06-30)
---------------------------------------------
* DATAES-175 - Release 1.2.1 (Fowler).
* DATAES-164 - CriteriaQuery equals method has to use AND operator instead of OR.
* DATAES-155 - findAll(Iterable<ID> ids) doesn't set persistent entity id.
Changes in version 1.3.0.M1 (2015-06-02)
----------------------------------------
* DATAES-168 - Release 1.3 M1 (Gosling).
* DATAES-164 - CriteriaQuery equals method has to use AND operator instead of OR.
* DATAES-162 - Adapt API changes in Spring Data Commons to simplify custom repository base class registration.
* DATAES-159 - Bulk update with ElasticsearchTemplate.
* DATAES-158 - UpdateRequest.script not working.
* DATAES-157 - support deleteBy operation.
* DATAES-155 - findAll(Iterable<ID> ids) doesn't set persistent entity id.
Changes in version 1.2.0.RELEASE (2015-03-23)
---------------------------------------------
* DATAES-154 - Release 1.2 GA.
Changes in version 1.2.0.RC1 (2015-03-05)
-----------------------------------------
* DATAES-152 - Release 1.2 RC1.
* DATAES-151 - findAll(Iterable<ID> ids) uses id representation in source instead of ES id.
* DATAES-140 - Document fields should not be indexed for search.
* DATAES-135 - Add necessary implementation for improved multi-store behavior.
* DATAES-132 - support include_in_parent for nested fieldtype.
* DATAES-130 - Allow Spring EL usage in type attribute of @Document.
* DATAES-129 - Custom Repository Method for simple geo request does not work.
* DATAES-115 - FindBy projections for list returns only 10 results.
* DATAES-100 - Allow configurable searchTimeout.
* DATAES-94 - Bump to support ES 1.2.0.
* DATAES-91 - Support for 'suggest' operations.
Changes in version 1.1.2.RELEASE (2015-01-28)
---------------------------------------------
* DATAES-146 - Release 1.1.2.
Changes in version 1.0.5.RELEASE (2015-01-27)
---------------------------------------------
* DATAES-145 - Release 1.0.5.
Changes in version 1.2.0.M1 (2014-12-01)
----------------------------------------
* DATAES-134 - Release 1.2 M1.
* DATAES-94 - Support for Elasticsearch 1.2.0.
* DATAES-76 - Add support for mapping generation of inherited fields.
Changes in version 1.1.1.RELEASE (2014-10-30)
---------------------------------------------
* DATAES-133 - Release 1.1.1.
Changes in version 1.1.0.RELEASE (2014-09-05)
---------------------------------------------
* DATAES-128 - Release 1.1 GA.
* DATAES-125 - the name of the isAnnotated method doesn't correspond to method body.
* DATAES-123 - Custom repository implementations are not picked up when using CDI.
* DATAES-120 - Polish reference documentation.
* DATAES-106 - Add support for countBy projections.
Changes in version 1.0.4.RELEASE (2014-08-27)
---------------------------------------------
* DATAES-122 - Release 1.0.4.
Changes in version 1.1.0.RC1 (2014-08-13)
-----------------------------------------
* DATAES-119 - Release 1.1 RC1.
* DATAES-117 - Displaying proper error message for entities that don't have an Id.
* DATAES-116 - Fix url typo in readme.md.
* DATAES-114 - Move to Asciidoctor for reference documentation.
* DATAES-113 - Add support for custom implementations in CDI repositories.
* DATAES-97 - UpdateQuery and UpdateBuilder should use UpdateRequest instead of the IndexRequest.
* DATAES-93 - Allow Spring EL usage in index name attribute of @Document.
* DATAES-89 - Support geolocation queries.
Changes in version 1.0.2.RELEASE (2014-07-28)
---------------------------------------------
* DATAES-107 - Release 1.0.2.
Changes in version 1.1.0.M1 (2014-07-10)
----------------------------------------
* DATAES-102 - Release 1.1 M1.
* DATAES-96 - Add support for aggregation in ElasticsearchTemplate.
* DATAES-94 - Bump to support ES 1.2.0.
Changes in version 1.0.1.RELEASE (2014-06-30)
---------------------------------------------
* DATAES-99 - Release 1.0.1.
Changes in version 1.0.0.RELEASE (2014-05-20)
---------------------------------------------
* DATAES-90 - Release 1.0 GA.
Changes in version 1.0.0.RC1 (2014-05-02)
-----------------------------------------
* DATAES-79 - Upgrade to elasticsearch 1.1.0.
* DATAES-78 - Release 1.0 M2.
* DATAES-74 - NPE in MappingElasticsearchEntityInformation.
* DATAES-73 - NullPointerException while persist a Map as part of persistent entity.
* DATAES-72 - Enhance Delete Index in ElasticsearchTemplate.
* DATAES-71 - Enhance Create Index in ElasticsearchTemplate.
* DATAES-69 - Sorting on String field not working.
* DATAES-67 - ElasticsearchTemplate#count does not respect specified index.
* DATAES-65 - Overhaul README.md.
* DATAES-64 - Add dynamic settings using @Setting annotation.
* DATAES-61 - Upgrade to elasticsearch 1.0.1.
* DATAES-60 - Java config support - default values in TransportClientFactoryBean.
* DATAES-56 - while specifying index and type at runtime indexing is failing.
* DATAES-55 - polish test cases and remove unwanted files.
* DATAES-54 - Upgrade to elasticsearch 1.0.
* DATAES-53 - @Field annotations (perhaps others?) ignored in included objects on mapping creation.
* DATAES-52 - Support Get & Multi Get.
* DATAES-51 - Allow for multiple sort builders when using NativeSearchQuery.
* DATAES-48 - Mapping for multiple level nested document is getting created wrong.
* DATAES-47 - Spring Application(Context) is not getting started up if elasticsearch nodes are not available.
* DATAES-46 - Remove unused imports & class.
* DATAES-35 - Investigate why build failed.
* DATAES-14 - Dynamic Search Type Support.
* DATAES-2 - Apply Spring Data formatting to sources.
Release Notes - Spring Data Elasticsearch - Version 1.0 M2 (2014-03-27)
-----------------------------------------------------------------------
** Bug
* DATAES-74 - NPE in MappingElasticsearchEntityInformation
* DATAES-73 - NullPointerException while persist a Map as part of persistent entity
* DATAES-69 - Sorting on String field not working
* DATAES-67 - ElasticsearchTemplate#count does not respect specified index
* DATAES-56 - while specifying index and type at runtime indexing is failing
* DATAES-53 - @Field annotations (perhaps others?) ignored in included objects on mapping creation
* DATAES-48 - Mapping for multiple level nested document is getting created wrong
* DATAES-35 - Investigate why build failed
* DATAES-72 - Enhance Delete Index in ElasticsearchTemplate
* DATAES-71 - Enhance Create Index in ElasticsearchTemplate
* DATAES-61 - Upgrade to elasticsearch 1.0.1
* DATAES-60 - Java config support - default values in TransportClientFactoryBean
* DATAES-54 - Upgrade to elasticsearch 1.0
* DATAES-47 - Spring Application(Context) is not getting started up if elasticsearch nodes are not available
* DATAES-14 - Dynamic Search Type Support
* DATAES-79 - Upgrade to elasticsearch 1.1.0
* DATAES-64 - Add dynamic settings using @Setting annotation
* DATAES-52 - Support Get & Multi Get
* DATAES-51 - Allow for multiple sort builders when using NativeSearchQuery
* DATAES-78 - Release 1.0 M2
* DATAES-65 - Overhaul README.md
* DATAES-55 - polish test cases and remove unwanted files
* DATAES-46 - Remove unused imports & class
* DATAES-2 - Apply Spring Data formatting to sources
* [DATAES-74] - NPE in MappingElasticsearchEntityInformation
* [DATAES-73] - NullPointerException while persist a Map as part of persistent entity
* [DATAES-69] - Sorting on String field not working
* [DATAES-67] - ElasticsearchTemplate#count does not respect specified index
* [DATAES-56] - while specifying index and type at runtime indexing is failing
* [DATAES-53] - @Field annotations (perhaps others?) ignored in included objects on mapping creation
* [DATAES-48] - Mapping for multiple level nested document is getting created wrong
* [DATAES-35] - Investigate why build failed
** Improvement
* [DATAES-72] - Enhance Delete Index in ElasticsearchTemplate
* [DATAES-71] - Enhance Create Index in ElasticsearchTemplate
* [DATAES-61] - Upgrade to elasticsearch 1.0.1
* [DATAES-60] - Java config support - default values in TransportClientFactoryBean
* [DATAES-54] - Upgrade to elasticsearch 1.0
* [DATAES-47] - Spring Application(Context) is not getting started up if elasticsearch nodes are not available
* [DATAES-14] - Dynamic Search Type Support
* [DATAES-79] - Upgrade to elasticsearch 1.1.0
** New Feature
* [DATAES-64] - Add dynamic settings using @Setting annotation
* [DATAES-52] - Support Get & Multi Get
* [DATAES-51] - Allow for multiple sort builders when using NativeSearchQuery
** Task
* [DATAES-78] - Release 1.0 M2
* [DATAES-65] - Overhaul README.md
* [DATAES-55] - polish test cases and remove unwanted files
* [DATAES-46] - Remove unused imports & class
* [DATAES-2] - Apply Spring Data formatting to sources
Release Notes - Spring Data Elasticsearch - Version 1.0 M1 (2014-02-07)
-----------------------------------------------------------------------
* DATAES-9 - multiple elasticsearch cluster nodes not getting parsed if using property file
* DATAES-7 - Migrate to the latest version of elasticsearch 0.90.0
* DATAES-11 - Missing core types in org.springframework.data.elasticsearch.annotations.FieldType
* DATAES-15 - Upgrade to latest version of elasticsearch( 0.90.2 )
* DATAES-19 - Delete specific type in an index, Type exists check
* DATAES-22 - Add support for TransportClient additional parameters such as client.transport.ignore_cluster_name, client.transport.ping_timeout, client.transport.nodes_sampler_interval
* DATAES-8 - Add support for Index level configuration
* DATAES-17 - Add support to retrieve highlighted text in search result
* DATAES-1 - Migrate sources to SpringSource GitHub repository
* DATAES-3 - Move to Spring Data build system
* DATAES-4 - Initial round of JavaDoc polish
* DATAES-5 - Add Apache license headers where necessary
* DATAES-6 - Add ability to let NodeClient clean up working directory
* DATAES-45 - Release 1.0 M1.
* #42 - org.springframework.data.elasticsearch.client.NodeClientFactoryBean' is not a valid value for 'anyURI'
* #40 - how to create index for json objects?
* #38 - Configure with native Client with embedded elasticsearch
* #37 - embedded elasticsearch client - how to recover data after process is restarted?
* #36 - FieldType.Date annotation
* #35 - @Transient property still inserted into elastic
* #33 - timestamp mapping
* #32 - BigDecimal @Field(type = FieldType.Double)
* #31 - DATAES-33: Mapping of parent-child relationships
* #29 - Added DefaultMapper support to map only partial fields from result instead of whole source field.
* #28 - Documentation (README.md) for Geo Location / Filter Feature
* #27 - Adding support for letting Elasticsearch generate Id for document
* #25 - Aliases
* #24 - DATAES-31 Adding ability to use ES Java API setSource directly
* #22 - spring-elasticsearch-1.0.xsd not found on www.springframework.com
* #21 - Autogenerated elastic search id isn't returned
* #20 - Exception while using CustomRepository
* #19 - Compilation issue with 0.90.5. (ElasticsearchTemplate.refresh API)
* #18 - problem with ES 0.9.5
* #17 - FacetResult extension is not possible
* #16 - Configuration of ObjectMapper in the ElasticsearchTemplate
* #15 - Added support for @Transient annotation to skip fields from mapping
* #14 - added format and pattern support for date fieldtype + fixed nullpointer...
* #12 - Where is the maven repository for this artifact?
* #11 - Build fails
* #10 - Elasticsearch + elasticsearch-river-rabbitmq
* #9 - MappingBuilder circular reference issue
* #8 - java.lang.NoSuchMethodError: org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty.isVersionProperty()Z
* #7 - Missing core types in org.springframework.data.elasticsearch.annotations.FieldType
* #6 - spirng-data-elasticsearch with elasticsearch-river-mongodb
+3 -3
View File
@@ -1,5 +1,5 @@
Spring Data Elasticsearch 1.0 M2
Copyright (c) [2013-2014] Pivotal Software, Inc.
Spring Data Elasticsearch 1.0.6
Copyright (c) [2013-2015] Pivotal Software, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License").
You may not use this product except in compliance with the License.
@@ -7,4 +7,4 @@ You may not use this product except in compliance with the License.
This product may include a number of subcomponents with
separate copyright notices and license terms. Your use of the source
code for the these subcomponents is subject to the terms and
conditions of the subcomponent's license, as noted in the LICENSE file.
conditions of the subcomponent's license, as noted in the LICENSE file.
@@ -0,0 +1,203 @@
/*
* Copyright 2014 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
*
* http://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;
import static org.apache.commons.lang.RandomStringUtils.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.builder.SampleEntityBuilder;
import org.springframework.data.elasticsearch.core.query.*;
import org.springframework.data.elasticsearch.entities.SampleEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mohsin Husen
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
public class AliasTests {
private static final String INDEX_NAME = "test-alias-index";
private static final String TYPE_NAME = "test-alias-type";
@Autowired
private ElasticsearchTemplate elasticsearchTemplate;
@Before
public void before() {
Map<String, Object> settings = new HashMap<String, Object>();
settings.put("index.refresh_interval", "-1");
settings.put("index.number_of_replicas", "0");
settings.put("index.number_of_shards", "2");
settings.put("index.store.type", "memory");
elasticsearchTemplate.deleteIndex(INDEX_NAME);
elasticsearchTemplate.createIndex(INDEX_NAME, settings);
elasticsearchTemplate.refresh(INDEX_NAME, true);
}
@Test
public void shouldAddAlias() {
// given
String aliasName = "test-alias";
AliasQuery aliasQuery = new AliasBuilder()
.withIndexName(INDEX_NAME)
.withAliasName(aliasName).build();
// when
elasticsearchTemplate.addAlias(aliasQuery);
// then
Set<String> aliases = elasticsearchTemplate.queryForAlias(INDEX_NAME);
assertThat(aliases, is(notNullValue()));
assertThat(aliases.contains(aliasName), is(true));
}
@Test
public void shouldRemoveAlias() {
// given
String indexName = INDEX_NAME;
String aliasName = "test-alias";
AliasQuery aliasQuery = new AliasBuilder()
.withIndexName(indexName)
.withAliasName(aliasName).build();
// when
elasticsearchTemplate.addAlias(aliasQuery);
Set<String> aliases = elasticsearchTemplate.queryForAlias(indexName);
assertThat(aliases, is(notNullValue()));
assertThat(aliases.contains(aliasName), is(true));
// then
elasticsearchTemplate.removeAlias(aliasQuery);
aliases = elasticsearchTemplate.queryForAlias(indexName);
assertThat(aliases, is(notNullValue()));
assertThat(aliases.size(), is(0));
}
/*
DATAES-70
*/
@Test
public void shouldAddAliasWithGivenRoutingValue() {
//given
String indexName = INDEX_NAME;
String alias = "test-alias";
AliasQuery aliasQuery = new AliasBuilder()
.withIndexName(indexName)
.withAliasName(alias)
.withRouting("0").build();
//when
elasticsearchTemplate.addAlias(aliasQuery);
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntityBuilder(documentId)
.message("some message")
.version(System.currentTimeMillis()).build();
IndexQuery indexQuery = new IndexQueryBuilder()
.withIndexName(alias)
.withId(sampleEntity.getId())
.withType(TYPE_NAME)
.withObject(sampleEntity)
.build();
elasticsearchTemplate.index(indexQuery);
elasticsearchTemplate.refresh(INDEX_NAME, true);
SearchQuery query = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
.withIndices(alias).withTypes(TYPE_NAME).build();
long count = elasticsearchTemplate.count(query);
//then
Set<String> aliases = elasticsearchTemplate.queryForAlias(INDEX_NAME);
assertThat(aliases, is(notNullValue()));
assertThat(aliases.contains(alias), is(true));
assertThat(count, is(1L));
//cleanup
elasticsearchTemplate.removeAlias(aliasQuery);
elasticsearchTemplate.deleteIndex(SampleEntity.class);
elasticsearchTemplate.createIndex(SampleEntity.class);
elasticsearchTemplate.putMapping(SampleEntity.class);
elasticsearchTemplate.refresh(SampleEntity.class, true);
}
/*
DATAES-70
*/
@Test
public void shouldAddAliasForVariousRoutingValues() {
//given
String alias1 = "test-alias-1";
String alias2 = "test-alias-2";
AliasQuery aliasQuery1 = new AliasBuilder()
.withIndexName(INDEX_NAME)
.withAliasName(alias1)
.withIndexRouting("0").build();
AliasQuery aliasQuery2 = new AliasBuilder()
.withIndexName(INDEX_NAME)
.withAliasName(alias2)
.withSearchRouting("1").build();
//when
elasticsearchTemplate.addAlias(aliasQuery1);
elasticsearchTemplate.addAlias(aliasQuery2);
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntityBuilder(documentId)
.message("some message")
.version(System.currentTimeMillis()).build();
IndexQuery indexQuery = new IndexQueryBuilder()
.withIndexName(alias1)
.withType(TYPE_NAME)
.withId(sampleEntity.getId())
.withObject(sampleEntity).build();
elasticsearchTemplate.index(indexQuery);
elasticsearchTemplate.refresh(SampleEntity.class, true);
SearchQuery query = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
.withIndices(alias2).withTypes(TYPE_NAME).build();
long count = elasticsearchTemplate.count(query, SampleEntity.class);
// then
Set<String> aliases = elasticsearchTemplate.queryForAlias(INDEX_NAME);
assertThat(aliases, is(notNullValue()));
assertThat(aliases.contains(alias1), is(true));
assertThat(aliases.contains(alias2), is(true));
assertThat(count, is(0L));
//cleanup
elasticsearchTemplate.removeAlias(aliasQuery1);
elasticsearchTemplate.removeAlias(aliasQuery2);
elasticsearchTemplate.deleteIndex(SampleEntity.class);
elasticsearchTemplate.createIndex(SampleEntity.class);
elasticsearchTemplate.putMapping(SampleEntity.class);
elasticsearchTemplate.refresh(SampleEntity.class, true);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@@ -23,6 +23,7 @@ import static org.junit.Assert.*;
import java.util.*;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.get.MultiGetItemResponse;
import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.action.index.IndexRequest;
@@ -42,8 +43,11 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.ElasticsearchException;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.builder.SampleEntityBuilder;
import org.springframework.data.elasticsearch.core.query.*;
import org.springframework.data.elasticsearch.entities.HetroEntity1;
import org.springframework.data.elasticsearch.entities.HetroEntity2;
import org.springframework.data.elasticsearch.entities.SampleEntity;
import org.springframework.data.elasticsearch.entities.SampleMappingEntity;
import org.springframework.test.context.ContextConfiguration;
@@ -53,12 +57,15 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Franck Marchand
* @author Abdul Mohammed
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
public class ElasticsearchTemplateTests {
private static final String INDEX_NAME = "test-index";
private static final String INDEX_1_NAME = "test-index-1";
private static final String INDEX_2_NAME = "test-index-2";
private static final String TYPE_NAME = "test-type";
@Autowired
@@ -68,6 +75,8 @@ public class ElasticsearchTemplateTests {
public void before() {
elasticsearchTemplate.deleteIndex(SampleEntity.class);
elasticsearchTemplate.createIndex(SampleEntity.class);
elasticsearchTemplate.deleteIndex(INDEX_1_NAME);
elasticsearchTemplate.deleteIndex(INDEX_2_NAME);
elasticsearchTemplate.refresh(SampleEntity.class, true);
}
@@ -585,6 +594,56 @@ public class ElasticsearchTemplateTests {
assertThat(sampleEntities.size(), is(equalTo(30)));
}
/*
DATAES-84
*/
@Test
public void shouldReturnResultsWithScanAndScrollForSpecifiedFields() {
//given
List<IndexQuery> entities = createSampleEntitiesWithMessage("Test message", 30);
// when
elasticsearchTemplate.bulkIndex(entities);
elasticsearchTemplate.refresh(SampleEntity.class, true);
// then
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
.withIndices(INDEX_NAME)
.withTypes(TYPE_NAME)
.withFields("message")
.withPageable(new PageRequest(0, 10))
.build();
String scrollId = elasticsearchTemplate.scan(searchQuery, 5000, false);
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
boolean hasRecords = true;
while (hasRecords) {
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L, new SearchResultMapper() {
@Override
public <T> FacetedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
List<SampleEntity> result = new ArrayList<SampleEntity>();
for(SearchHit searchHit : response.getHits()){
String message = searchHit.getFields().get("message").getValue();
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(searchHit.getId());
sampleEntity.setMessage(message);
result.add(sampleEntity);
}
if(result.size() > 0) {
return new FacetedPageImpl<T>((List<T>) result);
}
return null;
}
});
if (page != null) {
sampleEntities.addAll(page.getContent());
} else {
hasRecords = false;
}
}
assertThat(sampleEntities.size(), is(equalTo(30)));
}
@Test
public void shouldReturnResultsForScanAndScrollWithCustomResultMapper() {
//given
@@ -691,7 +750,6 @@ public class ElasticsearchTemplateTests {
@Test
public void shouldReturnListForGivenStringQuery() {
// given
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
// first document
String documentId = randomNumeric(5);
SampleEntity sampleEntity1 = new SampleEntityBuilder(documentId)
@@ -712,7 +770,7 @@ public class ElasticsearchTemplateTests {
.rate(15)
.version(System.currentTimeMillis()).build();
indexQueries = getIndexQueries(Arrays.asList(sampleEntity1, sampleEntity2, sampleEntity3));
List<IndexQuery> indexQueries = getIndexQueries(Arrays.asList(sampleEntity1, sampleEntity2, sampleEntity3));
// when
elasticsearchTemplate.bulkIndex(indexQueries);
@@ -890,44 +948,6 @@ public class ElasticsearchTemplateTests {
assertThat(sampleEntities.getTotalElements(), equalTo(0L));
}
@Test
public void shouldAddAlias() {
// given
elasticsearchTemplate.createIndex(SampleEntity.class);
String aliasName = "test-alias";
AliasQuery aliasQuery = new AliasBuilder()
.withIndexName(INDEX_NAME)
.withAliasName(aliasName).build();
// when
elasticsearchTemplate.addAlias(aliasQuery);
// then
Set<String> aliases = elasticsearchTemplate.queryForAlias(INDEX_NAME);
assertThat(aliases, is(notNullValue()));
assertThat(aliases.contains(aliasName), is(true));
}
@Test
public void shouldRemoveAlias() {
// given
elasticsearchTemplate.createIndex(SampleEntity.class);
String indexName = INDEX_NAME;
String aliasName = "test-alias";
AliasQuery aliasQuery = new AliasBuilder()
.withIndexName(indexName)
.withAliasName(aliasName).build();
// when
elasticsearchTemplate.addAlias(aliasQuery);
Set<String> aliases = elasticsearchTemplate.queryForAlias(indexName);
assertThat(aliases, is(notNullValue()));
assertThat(aliases.contains(aliasName), is(true));
// then
elasticsearchTemplate.removeAlias(aliasQuery);
aliases = elasticsearchTemplate.queryForAlias(indexName);
assertThat(aliases, is(notNullValue()));
assertThat(aliases.size(), is(0));
}
@Test
public void shouldIndexDocumentForSpecifiedSource() {
@@ -1357,29 +1377,28 @@ public class ElasticsearchTemplateTests {
@Test
public void shouldCreateIndexWithGivenSettings() {
// given
String settings =
"{ " +
"\"settings\" : { " +
"\"index\": { " +
"\"analysis\" :{ " +
"\"analyzer\": { " +
"\"email-analyzer\": { " +
"\"type\" : \"custom\"," +
"\"tokenizer\" : \"uax_url_email\"," +
"\"filter\" : [\"standard\", \"lowercase\", \"stop\"]\n" +
"}\n" +
"}\n" +
"}\n" +
"}\n" +
"}\n" +
"}";
String settings = "{\n" +
" \"index\": {\n" +
" \"number_of_shards\": \"1\",\n" +
" \"number_of_replicas\": \"0\",\n" +
" \"analysis\": {\n" +
" \"analyzer\": {\n" +
" \"emailAnalyzer\": {\n" +
" \"type\": \"custom\",\n" +
" \"tokenizer\": \"uax_url_email\"\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
"}";
elasticsearchTemplate.deleteIndex("test-index");
// when
elasticsearchTemplate.createIndex("test-index", settings);
// then
Map map = elasticsearchTemplate.getSetting("test-index");
boolean hasAnalyzer = map.containsKey("index.settings.index.analysis.analyzer.email-analyzer.tokenizer");
String emailAnalyzer = (String) map.get("index.settings.index.analysis.analyzer.email-analyzer.tokenizer");
boolean hasAnalyzer = map.containsKey("index.analysis.analyzer.emailAnalyzer.tokenizer");
String emailAnalyzer = (String) map.get("index.analysis.analyzer.emailAnalyzer.tokenizer");
assertThat(elasticsearchTemplate.indexExists("test-index"), is(true));
assertThat(hasAnalyzer, is(true));
assertThat(emailAnalyzer, is("uax_url_email"));
@@ -1406,6 +1425,115 @@ public class ElasticsearchTemplateTests {
assertThat((String) map.get("index.store.type"), is("memory"));
}
/*
DATAES-88
*/
@Test
public void shouldCreateIndexWithGivenClassAndSettings() {
//given
String settings = "{\n" +
" \"index\": {\n" +
" \"number_of_shards\": \"1\",\n" +
" \"number_of_replicas\": \"0\",\n" +
" \"analysis\": {\n" +
" \"analyzer\": {\n" +
" \"emailAnalyzer\": {\n" +
" \"type\": \"custom\",\n" +
" \"tokenizer\": \"uax_url_email\"\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
"}";
elasticsearchTemplate.deleteIndex(SampleEntity.class);
elasticsearchTemplate.createIndex(SampleEntity.class, settings);
elasticsearchTemplate.refresh(SampleEntity.class, true);
// then
Map map = elasticsearchTemplate.getSetting(SampleEntity.class);
assertThat(elasticsearchTemplate.indexExists("test-index"), is(true));
assertThat(map.containsKey("index.number_of_replicas"), is(true));
assertThat(map.containsKey("index.number_of_shards"), is(true));
assertThat((String) map.get("index.number_of_replicas"), is("0"));
assertThat((String) map.get("index.number_of_shards"), is("1"));
}
@Test
public void shouldTestResultsAcrossMultipleIndices() {
// given
String documentId1 = randomNumeric(5);
SampleEntity sampleEntity1 = new SampleEntityBuilder(documentId1).message("some message")
.version(System.currentTimeMillis()).build();
IndexQuery indexQuery1 = new IndexQueryBuilder().withId(sampleEntity1.getId())
.withIndexName("test-index-1")
.withObject(sampleEntity1)
.build();
String documentId2 = randomNumeric(5);
SampleEntity sampleEntity2 = new SampleEntityBuilder(documentId2).message("some test message")
.version(System.currentTimeMillis()).build();
IndexQuery indexQuery2 = new IndexQueryBuilder().withId(sampleEntity2.getId())
.withIndexName("test-index-2")
.withObject(sampleEntity2)
.build();
elasticsearchTemplate.bulkIndex(Arrays.asList(indexQuery1, indexQuery2));
elasticsearchTemplate.refresh("test-index-1", true);
elasticsearchTemplate.refresh("test-index-2", true);
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(matchAllQuery())
.withIndices("test-index-1", "test-index-2")
.build();
// when
List<SampleEntity> sampleEntities = elasticsearchTemplate.queryForList(searchQuery, SampleEntity.class);
// then
assertThat(sampleEntities.size(), is(equalTo(2)));
}
@Test
/**
* This is basically a demonstration to show composing entities out of heterogeneous indexes.
*/
public void shouldComposeObjectsReturnedFromHeterogeneousIndexes() {
// Given
HetroEntity1 entity1 = new HetroEntity1(randomNumeric(3), "aFirstName");
HetroEntity2 entity2 = new HetroEntity2(randomNumeric(4), "aLastName");
IndexQuery idxQuery1 = new IndexQueryBuilder().withIndexName(INDEX_1_NAME).withId(entity1.getId()).withObject(entity1).build();
IndexQuery idxQuery2 = new IndexQueryBuilder().withIndexName(INDEX_2_NAME).withId(entity2.getId()).withObject(entity2).build();
elasticsearchTemplate.bulkIndex(Arrays.asList(idxQuery1, idxQuery2));
elasticsearchTemplate.refresh(INDEX_1_NAME, true);
elasticsearchTemplate.refresh(INDEX_2_NAME, true);
// When
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).withTypes("hetro").withIndices(INDEX_1_NAME, INDEX_2_NAME).build();
Page<ResultAggregator> page = elasticsearchTemplate.queryForPage(searchQuery, ResultAggregator.class, new SearchResultMapper() {
@Override
public <T> FacetedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
List<ResultAggregator> values = new ArrayList<ResultAggregator>();
for (SearchHit searchHit : response.getHits()) {
String id = String.valueOf(searchHit.getSource().get("id"));
String firstName = StringUtils.isNotEmpty((String) searchHit.getSource().get("firstName")) ? (String) searchHit.getSource().get("firstName") : "";
String lastName = StringUtils.isNotEmpty((String) searchHit.getSource().get("lastName")) ? (String) searchHit.getSource().get("lastName") : "";
values.add(new ResultAggregator(id, firstName, lastName));
}
return new FacetedPageImpl<T>((List<T>) values);
}
});
assertThat(page.getTotalElements(), is(2l));
}
private IndexQuery getIndexQuery(SampleEntity sampleEntity) {
return new IndexQueryBuilder().withId(sampleEntity.getId()).withObject(sampleEntity).build();
}
@@ -1417,4 +1545,18 @@ public class ElasticsearchTemplateTests {
}
return indexQueries;
}
@Document(indexName = INDEX_2_NAME, replicas = 0, shards = 1)
class ResultAggregator {
private String id;
private String firstName;
private String lastName;
ResultAggregator(String id, String firstName, String lastName) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}
}
}
@@ -0,0 +1,121 @@
/*
* Copyright 2014 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
*
* http://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;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.facet.LogEntity;
import org.springframework.data.elasticsearch.core.facet.LogEntityBuilder;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* LogEntityTests
*
* @author Artur Konczak
* @author Mohsin Husen
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
public class LogEntityTests {
@Autowired
private ElasticsearchTemplate template;
@Before
public void before() throws ParseException {
template.deleteIndex(LogEntity.class);
template.createIndex(LogEntity.class);
template.putMapping(LogEntity.class);
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
IndexQuery indexQuery1 = new LogEntityBuilder("1").action("update").date(dateFormatter.parse("2013-10-18 18:01")).code(2)
.ip("10.10.10.1").buildIndex();
IndexQuery indexQuery2 = new LogEntityBuilder("2").action("update").date(dateFormatter.parse("2013-10-19 18:02")).code(2)
.ip("10.10.10.2").buildIndex();
IndexQuery indexQuery3 = new LogEntityBuilder("3").action("update").date(dateFormatter.parse("2013-10-19 18:03")).code(2)
.ip("10.10.10.3").buildIndex();
IndexQuery indexQuery4 = new LogEntityBuilder("4").action("update").date(dateFormatter.parse("2013-10-19 18:04")).code(2)
.ip("10.10.10.4").buildIndex();
template.bulkIndex(Arrays.asList(indexQuery1, indexQuery2, indexQuery3, indexQuery4));
template.refresh(LogEntity.class, true);
}
/*
DATAES-66
*/
@Test
public void shouldIndexGivenLogEntityWithIPFieldType() throws ParseException {
//when
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(termQuery("ip", "10.10.10.1")).build();
List<LogEntity> entities = template.queryForList(searchQuery, LogEntity.class);
//then
assertThat(entities, is(notNullValue()));
assertThat(entities.size(), is(1));
}
/*
DATAES-66
*/
@Test(expected = SearchPhaseExecutionException.class)
public void shouldThrowExceptionWhenInvalidIPGivenForSearchQuery() {
//when
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(termQuery("ip", "10.10.10")).build();
List<LogEntity> entities = template.queryForList(searchQuery, LogEntity.class);
//then
assertThat(entities, is(notNullValue()));
assertThat(entities.size(), is(1));
}
/*
DATAES-66
*/
@Test
public void shouldReturnLogsForGivenIPRanges() {
//when
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(rangeQuery("ip").from("10.10.10.1").to("10.10.10.3")).build();
List<LogEntity> entities = template.queryForList(searchQuery, LogEntity.class);
//then
assertThat(entities, is(notNullValue()));
assertThat(entities.size(), is(3));
}
}
@@ -473,6 +473,42 @@ public class ElasticsearchTemplateFacetTests {
assertThat(range.getTotal(), is(40.0));
}
@Test
public void shouldReturnKeyValueRangeFacetForStringValuesInGivenQuery() {
// given
String facetName = "rangeScoreOverYears";
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
.withFacet(
new RangeFacetRequestBuilder(facetName).fields(PUBLISHED_YEARS, "score")
.to("2000").range("2000", "2002").from("2002").build()
).build();
// when
FacetedPage<ArticleEntity> result = elasticsearchTemplate.queryForPage(searchQuery, ArticleEntity.class);
// then
assertThat(result.getNumberOfElements(), is(equalTo(4)));
RangeResult facet = (RangeResult) result.getFacet(facetName);
assertThat(facet.getRanges().size(), is(equalTo(3)));
Range range = facet.getRanges().get(0);
assertThat(range.getFrom(), nullValue());
assertThat(range.getTo(), is((double) YEAR_2000));
assertThat(range.getCount(), is(0L));
assertThat(range.getTotal(), is(0.0));
range = facet.getRanges().get(1);
assertThat(range.getFrom(), is((double) YEAR_2000));
assertThat(range.getTo(), is((double) YEAR_2002));
assertThat(range.getCount(), is(3L));
assertThat(range.getTotal(), is(90.0));
range = facet.getRanges().get(2);
assertThat(range.getFrom(), is((double) YEAR_2002));
assertThat(range.getTo(), nullValue());
assertThat(range.getCount(), is(1L));
assertThat(range.getTotal(), is(40.0));
}
@Test
public void shouldReturnStatisticalFacetForGivenQuery() {
// given
@@ -15,6 +15,8 @@
*/
package org.springframework.data.elasticsearch.core.facet;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -22,7 +24,6 @@ import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
/**
* Simple type to test facets
@@ -31,7 +32,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
* @author Mohsin Husen
*/
@Document(indexName = "logs", type = "log", shards = 1, replicas = 0, refreshInterval = "-1", indexStoreType = "memory")
@Document(indexName = "test-log-index", type = "test-log-type", shards = 1, replicas = 0, refreshInterval = "-1", indexStoreType = "memory")
public class LogEntity {
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@@ -43,7 +44,10 @@ public class LogEntity {
private long sequenceCode;
@Field(type = FieldType.Date, format = DateFormat.basic_date_time)
@Field(type = Ip)
private String ip;
@Field(type = Date, format = DateFormat.basic_date_time)
private Date date;
private LogEntity() {
@@ -81,6 +85,14 @@ public class LogEntity {
this.sequenceCode = sequenceCode;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public Date getDate() {
return date;
}
@@ -49,6 +49,11 @@ public class LogEntityBuilder {
return this;
}
public LogEntityBuilder ip(String ip) {
result.setIp(ip);
return this;
}
public LogEntity build() {
return result;
}
@@ -187,7 +187,9 @@ public class ElasticsearchTemplateGeoTests {
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
new Criteria("location").boundedBy(
new GeoBox(new GeoPoint(53.5171d, 0),
new GeoPoint(49.5171d, 0.2062d))));
new GeoPoint(49.5171d, 0.2062d))
)
);
//when
List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3, AuthorMarkerEntity.class);
@@ -217,7 +219,8 @@ public class ElasticsearchTemplateGeoTests {
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
new Criteria("location").boundedBy(
new GeoPoint(53.5171d, 0),
new GeoPoint(49.5171d, 0.2062d)));
new GeoPoint(49.5171d, 0.2062d))
);
//when
List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3, AuthorMarkerEntity.class);
@@ -38,7 +38,8 @@ public class SimpleElasticsearchPersistentEntityTests {
SimpleElasticsearchPersistentProperty persistentProperty = new SimpleElasticsearchPersistentProperty(
EntityWithWrongVersionType.class.getDeclaredField("version"), new PropertyDescriptor("version",
EntityWithWrongVersionType.class), new SimpleElasticsearchPersistentEntity<EntityWithWrongVersionType>(
typeInformation), new SimpleTypeHolder());
typeInformation), new SimpleTypeHolder()
);
// when
new SimpleElasticsearchPersistentEntity(typeInformation).addPersistentProperty(persistentProperty);
@@ -53,13 +54,15 @@ public class SimpleElasticsearchPersistentEntityTests {
EntityWithMultipleVersionField.class.getDeclaredField("version1"), new PropertyDescriptor("version1",
EntityWithMultipleVersionField.class),
new SimpleElasticsearchPersistentEntity<EntityWithMultipleVersionField>(typeInformation),
new SimpleTypeHolder());
new SimpleTypeHolder()
);
SimpleElasticsearchPersistentProperty persistentProperty2 = new SimpleElasticsearchPersistentProperty(
EntityWithMultipleVersionField.class.getDeclaredField("version2"), new PropertyDescriptor("version2",
EntityWithMultipleVersionField.class),
new SimpleElasticsearchPersistentEntity<EntityWithMultipleVersionField>(typeInformation),
new SimpleTypeHolder());
new SimpleTypeHolder()
);
SimpleElasticsearchPersistentEntity simpleElasticsearchPersistentEntity = new SimpleElasticsearchPersistentEntity(
typeInformation);
@@ -16,24 +16,21 @@
package org.springframework.data.elasticsearch.entities;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Setting;
import org.springframework.data.elasticsearch.annotations.*;
/**
* Sample SettingEntity for test out dynamic setting using @Setting Annotation
* Sample DynamicSettingAndMappingEntity for test out dynamic setting using @Setting Annotation
*
* @author Mohsin Husen
*/
@Setting(settingPath = "/settings/test-settings.json")
@Document(indexName = "test-setting-index", type = "test-setting-type")
public class SettingEntity {
@Setting(settingPath = "/settings/test-settings.json")
@Mapping(mappingPath = "/mappings/test-mappings.json")
public class DynamicSettingAndMappingEntity {
@Id
private String id;
private String name;
@Field(type = FieldType.String, searchAnalyzer = "emailAnalyzer", indexAnalyzer = "emailAnalyzer")
private String email;
public String getId() {
@@ -0,0 +1,83 @@
/*
* Copyright 2014 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
*
* http://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.entities;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Version;
import org.springframework.data.elasticsearch.annotations.Document;
/**
* @author Abdul Waheed
* @author Mohsin Husen
*/
@Document(indexName = "test-index-1", type = "hetro", replicas = 0, shards = 1)
public class HetroEntity1 {
@Id
private String id;
private String firstName;
@Version
private Long version;
public HetroEntity1(String id, String firstName) {
this.id = id;
this.firstName = firstName;
this.version = System.currentTimeMillis();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof SampleEntity)) {
return false;
}
if (this == obj) {
return true;
}
HetroEntity1 rhs = (HetroEntity1) obj;
return new EqualsBuilder().append(this.id, rhs.id).append(this.firstName, rhs.firstName).append(this.version, rhs.version).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(id).append(firstName).append(version).toHashCode();
}
}
@@ -0,0 +1,83 @@
/*
* Copyright 2014 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
*
* http://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.entities;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Version;
import org.springframework.data.elasticsearch.annotations.Document;
/**
* @author Abdul Waheed
* @author Mohsin Husen
*/
@Document(indexName = "test-index-2", type = "hetro", replicas = 0, shards = 1)
public class HetroEntity2 {
@Id
private String id;
private String lastName;
@Version
private Long version;
public HetroEntity2(String id, String lastName) {
this.id = id;
this.lastName = lastName;
this.version = System.currentTimeMillis();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof SampleEntity)) {
return false;
}
if (this == obj) {
return true;
}
HetroEntity2 rhs = (HetroEntity2) obj;
return new EqualsBuilder().append(this.id, rhs.id).append(this.lastName, rhs.lastName).append(this.version, rhs.version).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(id).append(lastName).append(version).toHashCode();
}
}
@@ -15,14 +15,14 @@
*/
package org.springframework.data.elasticsearch.repositories.setting;
import org.springframework.data.elasticsearch.entities.SettingEntity;
import org.springframework.data.elasticsearch.entities.DynamicSettingAndMappingEntity;
import org.springframework.data.elasticsearch.repository.ElasticsearchCrudRepository;
/**
* SettingEntityRepository
* DynamicSettingAndMappingEntityRepository
*
* @author Mohsin Husen
*/
public interface SettingEntityRepository extends ElasticsearchCrudRepository<SettingEntity, String>{
public interface DynamicSettingAndMappingEntityRepository extends ElasticsearchCrudRepository<DynamicSettingAndMappingEntity, String> {
}
@@ -0,0 +1,167 @@
/*
* Copyright 2014 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.elasticsearch.repositories.setting;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.RandomStringUtils;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.data.elasticsearch.entities.DynamicSettingAndMappingEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* DynamicSettingAndMappingEntityRepositoryTests
*
* @author Mohsin Husen
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:dynamic-settings-test.xml")
public class DynamicSettingAndMappingEntityRepositoryTests {
@Autowired
private DynamicSettingAndMappingEntityRepository repository;
@Autowired
private ElasticsearchTemplate elasticsearchTemplate;
@Before
public void before() {
elasticsearchTemplate.deleteIndex(DynamicSettingAndMappingEntity.class);
elasticsearchTemplate.createIndex(DynamicSettingAndMappingEntity.class);
elasticsearchTemplate.putMapping(DynamicSettingAndMappingEntity.class);
elasticsearchTemplate.refresh(DynamicSettingAndMappingEntity.class, true);
}
/*
DATAES-64
*/
@Test
public void shouldCreateGivenDynamicSettingsForGivenIndex() {
//given
//delete , create and apply mapping in before method
// then
assertThat(elasticsearchTemplate.indexExists(DynamicSettingAndMappingEntity.class), is(true));
Map map = elasticsearchTemplate.getSetting(DynamicSettingAndMappingEntity.class);
assertThat(map.containsKey("index.number_of_replicas"), is(true));
assertThat(map.containsKey("index.number_of_shards"), is(true));
assertThat(map.containsKey("index.analysis.analyzer.emailAnalyzer.tokenizer"), is(true));
assertThat((String) map.get("index.number_of_replicas"), is("0"));
assertThat((String) map.get("index.number_of_shards"), is("1"));
assertThat((String) map.get("index.analysis.analyzer.emailAnalyzer.tokenizer"), is("uax_url_email"));
}
/*
DATAES-64
*/
@Test
public void shouldSearchOnGivenTokenizerUsingGivenDynamicSettingsForGivenIndex() {
//given
DynamicSettingAndMappingEntity dynamicSettingAndMappingEntity1 = new DynamicSettingAndMappingEntity();
dynamicSettingAndMappingEntity1.setId(RandomStringUtils.randomNumeric(5));
dynamicSettingAndMappingEntity1.setName("test-setting1");
dynamicSettingAndMappingEntity1.setEmail("test_setting1@test.com");
repository.save(dynamicSettingAndMappingEntity1);
DynamicSettingAndMappingEntity dynamicSettingAndMappingEntity2 = new DynamicSettingAndMappingEntity();
dynamicSettingAndMappingEntity2.setId(RandomStringUtils.randomNumeric(5));
dynamicSettingAndMappingEntity2.setName("test-setting2");
dynamicSettingAndMappingEntity2.setEmail("test_setting2@test.com");
repository.save(dynamicSettingAndMappingEntity2);
//when
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.termQuery("email", dynamicSettingAndMappingEntity1.getEmail())).build();
long count = elasticsearchTemplate.count(searchQuery, DynamicSettingAndMappingEntity.class);
List<DynamicSettingAndMappingEntity> entityList = elasticsearchTemplate.queryForList(searchQuery, DynamicSettingAndMappingEntity.class);
//then
assertThat(count, is(1L));
assertThat(entityList, is(notNullValue()));
assertThat(entityList.size(), is(1));
assertThat(entityList.get(0).getEmail(), is(dynamicSettingAndMappingEntity1.getEmail()));
}
@Test
public void shouldGetMappingForGivenIndexAndType() {
//given
//delete , create and apply mapping in before method
//when
Map mapping = elasticsearchTemplate.getMapping(DynamicSettingAndMappingEntity.class);
//then
Map properties = (Map) mapping.get("properties");
assertThat(mapping, is(notNullValue()));
assertThat(properties, is(notNullValue()));
assertThat(((String) ((Map) properties.get("email")).get("type")), is("string"));
assertThat((String) ((Map)properties.get("email")).get("analyzer"), is("emailAnalyzer"));
}
@Test
public void shouldCreateMappingWithSpecifiedMappings() {
//given
elasticsearchTemplate.deleteIndex(DynamicSettingAndMappingEntity.class);
elasticsearchTemplate.createIndex(DynamicSettingAndMappingEntity.class);
elasticsearchTemplate.refresh(DynamicSettingAndMappingEntity.class, true);
//when
String mappings = "{\n" +
" \"test-setting-type\" : {\n" +
" \"properties\" : {\n" +
" \"email\" : {\"type\" : \"string\", \"analyzer\" : \"emailAnalyzer\" }\n" +
" }\n" +
" }\n" +
"}";
elasticsearchTemplate.putMapping(DynamicSettingAndMappingEntity.class, mappings);
elasticsearchTemplate.refresh(DynamicSettingAndMappingEntity.class, true);
//then
Map mapping = elasticsearchTemplate.getMapping(DynamicSettingAndMappingEntity.class);
Map properties = (Map) mapping.get("properties");
assertThat(mapping, is(notNullValue()));
assertThat(properties, is(notNullValue()));
assertThat(((String) ((Map) properties.get("email")).get("type")), is("string"));
assertThat((String) ((Map)properties.get("email")).get("analyzer"), is("emailAnalyzer"));
}
/*
DATAES-86
*/
@Test
public void shouldCreateMappingWithUsingMappingAnnotation() {
//given
//then
Map mapping = elasticsearchTemplate.getMapping(DynamicSettingAndMappingEntity.class);
Map properties = (Map) mapping.get("properties");
assertThat(mapping, is(notNullValue()));
assertThat(properties, is(notNullValue()));
assertThat(((String) ((Map) properties.get("email")).get("type")), is("string"));
assertThat((String) ((Map)properties.get("email")).get("analyzer"), is("emailAnalyzer"));
}
}
@@ -1,112 +0,0 @@
/*
* Copyright 2014 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.elasticsearch.repositories.setting;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.RandomStringUtils;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.data.elasticsearch.entities.SettingEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* SettingEntityRepositoryTest
*
* @author Mohsin Husen
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:dynamic-settings-test.xml")
public class SettingEntityRepositoryTest {
@Autowired
private SettingEntityRepository repository;
@Autowired
private ElasticsearchTemplate elasticsearchTemplate;
@Before
public void before() {
elasticsearchTemplate.deleteIndex(SettingEntity.class);
elasticsearchTemplate.createIndex(SettingEntity.class);
elasticsearchTemplate.putMapping(SettingEntity.class);
elasticsearchTemplate.refresh(SettingEntity.class, true);
}
/*
DATAES-64
*/
@Test
public void shouldCreateGivenDynamicSettingsForGivenIndex() {
//given
//delete , create and apply mapping in before method
// then
assertThat(elasticsearchTemplate.indexExists(SettingEntity.class), is(true));
Map map = elasticsearchTemplate.getSetting(SettingEntity.class);
assertThat(map.containsKey("index.number_of_replicas"), is(true));
assertThat(map.containsKey("index.number_of_shards"), is(true));
assertThat(map.containsKey("index.analysis.analyzer.emailAnalyzer.tokenizer"), is(true));
assertThat((String) map.get("index.number_of_replicas"), is("0"));
assertThat((String) map.get("index.number_of_shards"), is("1"));
assertThat((String) map.get("index.analysis.analyzer.emailAnalyzer.tokenizer"), is("uax_url_email"));
}
/*
DATAES-64
*/
@Test
public void shouldSearchOnGivenTokenizerUsingGivenDynamicSettingsForGivenIndex() {
//given
SettingEntity settingEntity1 = new SettingEntity();
settingEntity1.setId(RandomStringUtils.randomNumeric(5));
settingEntity1.setName("test-setting1");
settingEntity1.setEmail("test_setting1@test.com");
repository.save(settingEntity1);
SettingEntity settingEntity2 = new SettingEntity();
settingEntity2.setId(RandomStringUtils.randomNumeric(5));
settingEntity2.setName("test-setting2");
settingEntity2.setEmail("test_setting2@test.com");
repository.save(settingEntity2);
//when
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.termQuery("email", settingEntity1.getEmail())).build();
long count = elasticsearchTemplate.count(searchQuery, SettingEntity.class);
List<SettingEntity> entityList = elasticsearchTemplate.queryForList(searchQuery, SettingEntity.class);
//then
assertThat(count, is(1L));
assertThat(entityList, is(notNullValue()));
assertThat(entityList.size(), is(1));
assertThat(entityList.get(0).getEmail(), is(settingEntity1.getEmail()));
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@@ -24,8 +24,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.elasticsearch.common.collect.Lists;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -204,10 +204,11 @@ public class SimpleElasticsearchRepositoryTests {
assertThat(page.getNumberOfElements(), is(greaterThanOrEqualTo(1)));
}
/*
DATAES-82
*/
@Test
@Ignore
public void shouldFindAllByIdQuery() {
// todo : find solution for findAll(Iterable<Ids> ids)
// given
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntity();
@@ -228,6 +229,8 @@ public class SimpleElasticsearchRepositoryTests {
// then
assertNotNull("sample entities cant be null..", sampleEntities);
List<SampleEntity> entities = Lists.newArrayList(sampleEntities);
assertThat(entities.size(), is(2));
}
@Test
+1 -1
View File
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<import resource="infrastructure.xml"/>
<import resource="infrastructure.xml"/>
<bean name="elasticsearchTemplate"
class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
+1 -1
View File
@@ -7,6 +7,6 @@
<elasticsearch:node-client id="client" local="true" cluster-name="testCluster" http-enabled="false"/>
<!--<elasticsearch:transport-client id="client" cluster-name="elasticsearch" cluster-nodes="127.0.1.1:9300" />-->
<!--<elasticsearch:transport-client id="client" cluster-name="elasticsearch" cluster-nodes="127.0.0.1:9300" />-->
</beans>
@@ -0,0 +1,7 @@
{
"test-setting-type" : {
"properties" : {
"email" : {"type" : "string", "analyzer" : "emailAnalyzer" }
}
}
}
@@ -1,14 +1,14 @@
{
"index": {
"number_of_shards" : "1",
"number_of_replicas" : "0",
"analysis" :{
"analyzer": {
"emailAnalyzer": {
"type" : "custom",
"tokenizer" : "uax_url_email"
}
"index": {
"number_of_shards": "1",
"number_of_replicas": "0",
"analysis": {
"analyzer": {
"emailAnalyzer": {
"type": "custom",
"tokenizer": "uax_url_email"
}
}
}
}
}
+2 -2
View File
@@ -11,8 +11,8 @@ Import-Template:
org.apache.commons.collections.*;version="${commonscollections:[=.=.=,+1.0.0)}";resolution:=optional,
org.apache.commons.lang.*;version="${commonslang:[=.=.=,+1.0.0)}",
com.fasterxml.jackson.*;version="${jackson:[=.=.=,+1.0.0)}";resolution:=optional,
org.elasticsearch.*;version="${elasticsearch:[=.=.=,+1.0.0)}",
org.apache.lucene.*;version="4.6.1",
org.elasticsearch.*;version="${elasticsearch:[=.=.=,+1.1.1)}",
org.apache.lucene.*;version="4.7.2",
org.joda.time.*;version="${jodatime:[=.=.=,+1.0.0)}",
org.slf4j.*;version="${slf4j:[=.=.=,+1.0.0)}",
org.springframework.*;version="${spring:[=.=.=.=,+1.0.0)}",