Compare commits
191 Commits
5.5.13
...
2.1.23.RELEASE
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d2cd4b658 | |||
| 28d2a2ffa2 | |||
| 1fa0274a74 | |||
| 41c3f8457d | |||
| feed4dbc9c | |||
| 2299dced1f | |||
| 1d7caf7d99 | |||
| f11786259c | |||
| bd9e42e890 | |||
| f17d403089 | |||
| c1e8f4675e | |||
| 106b0ce156 | |||
| 1b500cfff2 | |||
| 9f5821c63b | |||
| 03d317e9c4 | |||
| 27922c3dc2 | |||
| 1aad042bc4 | |||
| d0bf5744e4 | |||
| b840fc9903 | |||
| e58c4ccb1f | |||
| 319dcf50ed | |||
| 026a1638eb | |||
| ac035674de | |||
| b3a3f9bd57 | |||
| c9e69f5e0b | |||
| 6f402cc2cc | |||
| 44b76ba242 | |||
| 526880e596 | |||
| 2d75f5a700 | |||
| d7414776c3 | |||
| 637cb62f80 | |||
| 5c9c0b109c | |||
| d75806298d | |||
| 583406bd29 | |||
| 5bb66f72d1 | |||
| 982107c756 | |||
| 3aa5bbd09b | |||
| 5f184fea37 | |||
| 4bfaee2306 | |||
| 2f1738b648 | |||
| ac7fc8f034 | |||
| 4b87307e00 | |||
| 46e60679dc | |||
| a0b3007443 | |||
| 5645962915 | |||
| 0e9e3ce932 | |||
| 13139cad6a | |||
| 2fa2fa48db | |||
| 4a1687fda5 | |||
| 2ac7bd7a21 | |||
| c81a3c592c | |||
| eae70ed5da | |||
| 6ff3bb7c41 | |||
| 364e846b11 | |||
| ce06305beb | |||
| b0977e8ada | |||
| 0a2ecaaf77 | |||
| 837565f8fc | |||
| fa32a2b4b6 | |||
| cbacbe48f7 | |||
| a1bf73201f | |||
| ec15e644b0 | |||
| b778fc6ef7 | |||
| 6e389bb1bc | |||
| be41115cc9 | |||
| 731a2857a1 | |||
| e09e43ff65 | |||
| 1e54de707b | |||
| ccfdc0c1cb | |||
| e505dcf609 | |||
| 515ce8a55e | |||
| 6192f454c1 | |||
| 1b4fe21230 | |||
| d48b1e51a6 | |||
| 7b8d6bfd89 | |||
| 24ebd61d42 | |||
| 635cdaa01f | |||
| 6b56d805cf | |||
| d9ef96b683 | |||
| 5ccb1059c1 | |||
| 762a9bb99f | |||
| 827aea4386 | |||
| f568c2e7d5 | |||
| b35080bdb0 | |||
| e2c3a3f7aa | |||
| a546498385 | |||
| 23f20f7b1f | |||
| 1970d98232 | |||
| 3e02b17a7a | |||
| a5b8dd71fd | |||
| 31c1d0ea30 | |||
| 275402149a | |||
| f82673c762 | |||
| b4548d9272 | |||
| b07d8b0a49 | |||
| 1c0fff63d6 | |||
| feb59fa538 | |||
| 74164089cd | |||
| 81690cd449 | |||
| 4f55f7cc0c | |||
| c3ba55d825 | |||
| 53e87ec787 | |||
| a6bc04c679 | |||
| 2e36e85bd7 | |||
| b7279d57e9 | |||
| aaa17b55d6 | |||
| ef8767535c | |||
| 26ecb5c1dc | |||
| 0b974456e2 | |||
| 63a16453fc | |||
| 7d8a78d728 | |||
| 230d616fe3 | |||
| e22b1b2c82 | |||
| 8906ce0385 | |||
| 41dda8337a | |||
| 481e4e35b6 | |||
| da924ba62c | |||
| 462f1dd85a | |||
| 1ddea11287 | |||
| c352a1d3af | |||
| 93893c3393 | |||
| d3777b2161 | |||
| d7b94e53a5 | |||
| 4daadf0d98 | |||
| 988828cbbd | |||
| a49efc99b6 | |||
| ff2aa58de3 | |||
| 3e0a36227e | |||
| 5863335114 | |||
| e3d0cd1102 | |||
| 9eeba8f517 | |||
| 7cba3b9d60 | |||
| a2ab0e413d | |||
| 44c6b5d38e | |||
| 727fec4712 | |||
| 7e6b2dba14 | |||
| 38475e6eac | |||
| 3626be42fd | |||
| 4e97dd39e5 | |||
| 879c90f5ce | |||
| ccf055c087 | |||
| 15f6de1e63 | |||
| 0c9354bb50 | |||
| a48c4838eb | |||
| 354eba3bc1 | |||
| 1a86e12fc7 | |||
| 9c14e0b9b7 | |||
| 933fbcb975 | |||
| 7660cef804 | |||
| 160ae17ce8 | |||
| 424c4c64e3 | |||
| df93e2aa88 | |||
| 29a52c4f36 | |||
| 74b2d46029 | |||
| 8af517e611 | |||
| 05bace213b | |||
| 2a70ee11ba | |||
| 0591435f99 | |||
| 072fb3465a | |||
| a6dc02aa51 | |||
| 5a3a49cc3e | |||
| f1559d3b55 | |||
| 9a9d95ba15 | |||
| b873c5409c | |||
| 6aa4adc977 | |||
| 2c7d8c6f61 | |||
| 05c9804d16 | |||
| c72eaa79e9 | |||
| 399611d68a | |||
| f79caa9626 | |||
| b8ff15e69c | |||
| c28f41a2c4 | |||
| 686921c46e | |||
| d1e11ef5f9 | |||
| c0ef590038 | |||
| 692142ea65 | |||
| 6e2331b040 | |||
| 29910fc9ef | |||
| 38604eb64d | |||
| 344f439778 | |||
| ea07d697ad | |||
| 6b549339c8 | |||
| 3c2894e45d | |||
| d921f9d9a3 | |||
| af1f658712 | |||
| 18c30078ba | |||
| 812e202f15 | |||
| bf4cadbdd8 | |||
| 200f1771d5 | |||
| b83a097892 | |||
| 6d08e92117 |
@@ -1,9 +1,12 @@
|
|||||||
|
<!--
|
||||||
|
|
||||||
Thank you for proposing a pull request. This template will guide you through the essential steps necessary for a pull request.
|
Thank you for proposing a pull request. This template will guide you through the essential steps necessary for a pull request.
|
||||||
Make sure that:
|
Make sure that:
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
- [ ] You have read the [Spring Data contribution guidelines](https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.adoc).
|
- [ ] You have read the [Spring Data contribution guidelines](https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.adoc).
|
||||||
- [ ] There is a ticket in the bug tracker for the project in our [JIRA](https://jira.spring.io/browse/DATAES).
|
- [ ] There is a ticket in the bug tracker for the project in our [JIRA](https://jira.spring.io/browse/DATAES).
|
||||||
- [ ] You use the code formatters provided [here](https://github.com/spring-projects/spring-data-build/tree/master/etc/ide) and have them applied to your changes. Don’t submit any formatting related changes.
|
- [ ] You use the code formatters provided [here](https://github.com/spring-projects/spring-data-build/tree/master/etc/ide) and have them applied to your changes. Don’t submit any formatting related changes.
|
||||||
- [ ] You submit test cases (unit or integration tests) that back your changes.
|
- [ ] You submit test cases (unit or integration tests) that back your changes.
|
||||||
- [ ] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).
|
- [ ] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).
|
||||||
- [ ] You provide your full name and an email address registered with your GitHub account. If you’re a first-time submitter, make sure you have completed the [Contributor’s License Agreement form](https://support.springsource.com/spring_committer_signup).
|
|
||||||
+21
-21
@@ -1,21 +1,21 @@
|
|||||||
atlassian-ide-plugin.xml
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
## Ignore svn files
|
## Ignore svn files
|
||||||
.svn
|
.svn
|
||||||
|
|
||||||
## ignore any target dir
|
## ignore any target dir
|
||||||
target
|
target
|
||||||
|
|
||||||
##ignore only top level data dir - local node data files for unit tests
|
##ignore only top level data dir - local node data files for unit tests
|
||||||
/data
|
/data
|
||||||
|
|
||||||
## Ignore project files created by Eclipse
|
## Ignore project files created by Eclipse
|
||||||
.settings
|
.settings
|
||||||
.project
|
.project
|
||||||
.classpath
|
.classpath
|
||||||
|
|
||||||
## Ignore project files created by IntelliJ IDEA
|
## Ignore project files created by IntelliJ IDEA
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
*.iws
|
||||||
.idea
|
.idea
|
||||||
|
|||||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
= Continuous Integration
|
||||||
|
|
||||||
|
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-elasticsearch%2Fmaster&subject=Moore%20(master)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-elasticsearch/]
|
||||||
|
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-elasticsearch%2F3.1.x&subject=Lovelace%20(3.1.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-elasticsearch/]
|
||||||
|
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-elasticsearch%2F2.1.x&subject=Ingalls%20(2.1.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-elasticsearch/]
|
||||||
|
|
||||||
|
== Running CI tasks locally
|
||||||
|
|
||||||
|
Since this pipeline is purely Docker-based, it's easy to:
|
||||||
|
|
||||||
|
* Debug what went wrong on your local machine.
|
||||||
|
* Test out a a tweak to your `test.sh` script before sending it out.
|
||||||
|
* Experiment against a new image before submitting your pull request.
|
||||||
|
|
||||||
|
All of these use cases are great reasons to essentially run what the CI server does on your local machine.
|
||||||
|
|
||||||
|
IMPORTANT: To do this you must have Docker installed on your machine.
|
||||||
|
|
||||||
|
1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-data-elasticsearch-github adoptopenjdk/openjdk8:latest /bin/bash`
|
||||||
|
+
|
||||||
|
This will launch the Docker image and mount your source code at `spring-data-elasticsearch-github`.
|
||||||
|
+
|
||||||
|
2. `cd spring-data-elasticsearch-github`
|
||||||
|
+
|
||||||
|
Next, run your tests from inside the container:
|
||||||
|
+
|
||||||
|
3. `./mvnw clean dependency:list test -Dsort` (or whatever profile you need to test out)
|
||||||
|
|
||||||
|
Since the container is binding to your source, you can make edits from your IDE and continue to run build jobs.
|
||||||
|
|
||||||
|
If you need to package things up, do this:
|
||||||
|
|
||||||
|
1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-data-elasticsearch-github adoptopenjdk/openjdk8:latest /bin/bash`
|
||||||
|
+
|
||||||
|
This will launch the Docker image and mount your source code at `spring-data-elasticsearch-github`.
|
||||||
|
+
|
||||||
|
2. `cd spring-data-elasticsearch-github`
|
||||||
|
+
|
||||||
|
Next, try to package everything up from inside the container:
|
||||||
|
+
|
||||||
|
3. `./mvnw -Pci,snapshot -Dmaven.test.skip=true clean package`
|
||||||
|
|
||||||
|
NOTE: Docker containers can eat up disk space fast! From time to time, run `docker system prune` to clean out old images.
|
||||||
Vendored
+115
@@ -0,0 +1,115 @@
|
|||||||
|
pipeline {
|
||||||
|
agent none
|
||||||
|
|
||||||
|
triggers {
|
||||||
|
pollSCM 'H/10 * * * *'
|
||||||
|
upstream(upstreamProjects: "spring-data-commons/1.13.x", threshold: hudson.model.Result.SUCCESS)
|
||||||
|
}
|
||||||
|
|
||||||
|
options {
|
||||||
|
disableConcurrentBuilds()
|
||||||
|
buildDiscarder(logRotator(numToKeepStr: '14'))
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage("Test") {
|
||||||
|
when {
|
||||||
|
anyOf {
|
||||||
|
branch '2.1.x'
|
||||||
|
not { triggeredBy 'UpstreamCause' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parallel {
|
||||||
|
stage("test: baseline") {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'adoptopenjdk/openjdk8:latest'
|
||||||
|
label 'data'
|
||||||
|
args '-v $HOME:/tmp/jenkins-home'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
steps {
|
||||||
|
sh 'rm -rf ?'
|
||||||
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Dsort -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Release to artifactory') {
|
||||||
|
when {
|
||||||
|
branch 'issue/*'
|
||||||
|
not { triggeredBy 'UpstreamCause' }
|
||||||
|
}
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'adoptopenjdk/openjdk8:latest'
|
||||||
|
label 'data'
|
||||||
|
args '-v $HOME:/tmp/jenkins-home'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options { timeout(time: 20, unit: 'MINUTES') }
|
||||||
|
|
||||||
|
environment {
|
||||||
|
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
||||||
|
}
|
||||||
|
|
||||||
|
steps {
|
||||||
|
sh 'rm -rf ?'
|
||||||
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,artifactory ' +
|
||||||
|
'-Dartifactory.server=https://repo.spring.io ' +
|
||||||
|
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||||
|
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||||
|
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
||||||
|
"-Dartifactory.build-name=spring-data-elasticsearch-2.1 " +
|
||||||
|
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
||||||
|
'-Dmaven.test.skip=true clean deploy -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Release to artifactory with docs') {
|
||||||
|
when {
|
||||||
|
branch '2.1.x'
|
||||||
|
}
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'adoptopenjdk/openjdk8:latest'
|
||||||
|
label 'data'
|
||||||
|
args '-v $HOME:/tmp/jenkins-home'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options { timeout(time: 20, unit: 'MINUTES') }
|
||||||
|
|
||||||
|
environment {
|
||||||
|
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
||||||
|
}
|
||||||
|
|
||||||
|
steps {
|
||||||
|
sh 'rm -rf ?'
|
||||||
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,artifactory ' +
|
||||||
|
'-Dartifactory.server=https://repo.spring.io ' +
|
||||||
|
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||||
|
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||||
|
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
||||||
|
"-Dartifactory.build-name=spring-data-elasticsearch-2.1 " +
|
||||||
|
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
||||||
|
'-Dmaven.test.skip=true clean deploy -B'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
changed {
|
||||||
|
script {
|
||||||
|
slackSend(
|
||||||
|
color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger',
|
||||||
|
channel: '#spring-data-dev',
|
||||||
|
message: "${currentBuild.fullDisplayName} - `${currentBuild.currentResult}`\n${env.BUILD_URL}")
|
||||||
|
emailext(
|
||||||
|
subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}",
|
||||||
|
mimeType: 'text/html',
|
||||||
|
recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']],
|
||||||
|
body: "<a href=\"${env.BUILD_URL}\">${currentBuild.fullDisplayName} is reported as ${currentBuild.currentResult}</a>")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+201
@@ -0,0 +1,201 @@
|
|||||||
|
image:https://spring.io/badges/spring-data-elasticsearch/ga.svg[Spring Data Elasticsearch,link=https://projects.spring.io/spring-data-elasticsearch#quick-start] image:https://spring.io/badges/spring-data-elasticsearch/snapshot.svg[Spring Data Elasticsearch,link=https://projects.spring.io/spring-data-elasticsearch#quick-start]
|
||||||
|
|
||||||
|
= Spring Data for Elasticsearch image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-elasticsearch%2Fmaster&subject=Build[link=https://jenkins.spring.io/view/SpringData/job/spring-data-elasticsearch/] https://gitter.im/spring-projects/spring-data[image:https://badges.gitter.im/spring-projects/spring-data.svg[Gitter]]
|
||||||
|
|
||||||
|
The primary goal of the https://projects.spring.io/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
|
||||||
|
|
||||||
|
The Spring Data Elasticsearch project provides integration with the https://www.elastic.co/[Elasticsearch] search engine. Key functional areas of Spring Data Elasticsearch are a POJO centric model for interacting with a Elasticsearch Documents and easily writing a Repository style data access layer.
|
||||||
|
|
||||||
|
This project is lead and maintained by the community.
|
||||||
|
|
||||||
|
== Features
|
||||||
|
|
||||||
|
* Spring configuration support using Java based `@Configuration` classes or an XML namespace for a ES clients instances.
|
||||||
|
* `ElasticsearchTemplate` helper class that increases productivity performing common ES operations. Includes integrated object mapping between documents and POJOs.
|
||||||
|
* Feature Rich Object Mapping integrated with Spring’s Conversion Service
|
||||||
|
* Annotation based mapping metadata but extensible to support other metadata formats
|
||||||
|
* Automatic implementation of `Repository` interfaces including support for custom finder methods.
|
||||||
|
* CDI support for repositories
|
||||||
|
|
||||||
|
== Code of Conduct
|
||||||
|
|
||||||
|
This project is governed by the link:CODE_OF_CONDUCT.adoc[Spring Code of Conduct]. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.
|
||||||
|
|
||||||
|
== Getting Started
|
||||||
|
|
||||||
|
Here is a quick teaser of an application using Spring Data Repositories in Java:
|
||||||
|
|
||||||
|
[source,java]
|
||||||
|
----
|
||||||
|
public interface PersonRepository extends CrudRepository<Person, Long> {
|
||||||
|
|
||||||
|
List<Person> findByLastname(String lastname);
|
||||||
|
|
||||||
|
List<Person> findByFirstnameLike(String firstname);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MyService {
|
||||||
|
|
||||||
|
private final PersonRepository repository;
|
||||||
|
|
||||||
|
public MyService(PersonRepository repository) {
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doWork() {
|
||||||
|
|
||||||
|
repository.deleteAll();
|
||||||
|
|
||||||
|
Person person = new Person();
|
||||||
|
person.setFirstname("Oliver");
|
||||||
|
person.setLastname("Gierke");
|
||||||
|
repository.save(person);
|
||||||
|
|
||||||
|
List<Person> lastNameResults = repository.findByLastname("Gierke");
|
||||||
|
List<Person> firstNameResults = repository.findByFirstnameLike("Oli*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
Using Node Client
|
||||||
|
|
||||||
|
[source,xml]
|
||||||
|
----
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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 https://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd
|
||||||
|
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
|
||||||
|
<elasticsearch:node-client id="client" local="true"/>
|
||||||
|
|
||||||
|
<bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
|
||||||
|
<constructor-arg name="client" ref="client"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
||||||
|
----
|
||||||
|
|
||||||
|
Using Transport Client
|
||||||
|
|
||||||
|
[source,xml]
|
||||||
|
----
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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 https://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd
|
||||||
|
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
|
||||||
|
<elasticsearch:repositories base-package="com.xyz.acme"/>
|
||||||
|
|
||||||
|
<elasticsearch:transport-client id="client" cluster-nodes="ip:9300,ip:9300" cluster-name="elasticsearch" />
|
||||||
|
|
||||||
|
<bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
|
||||||
|
<constructor-arg name="client" ref="client"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
||||||
|
----
|
||||||
|
|
||||||
|
=== Maven configuration
|
||||||
|
|
||||||
|
Add the Maven dependency:
|
||||||
|
|
||||||
|
[source,xml]
|
||||||
|
----
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-elasticsearch</artifactId>
|
||||||
|
<version>${version}.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
----
|
||||||
|
|
||||||
|
**Compatibility Matrix**
|
||||||
|
|
||||||
|
[cols="^,^"]
|
||||||
|
|===
|
||||||
|
|Spring Data Elasticsearch | Elasticsearch
|
||||||
|
|3.2.x |6.7.2
|
||||||
|
|3.1.x |6.2.2
|
||||||
|
|3.0.x |5.5.0
|
||||||
|
|2.1.x |2.4.0
|
||||||
|
|2.0.x |2.2.0
|
||||||
|
|1.3.x |1.5.2
|
||||||
|
|===
|
||||||
|
|
||||||
|
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.
|
||||||
|
|
||||||
|
[source,xml]
|
||||||
|
----
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-elasticsearch</artifactId>
|
||||||
|
<version>${version}.BUILD-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>spring-libs-snapshot</id>
|
||||||
|
<name>Spring Snapshot Repository</name>
|
||||||
|
<url>https://repo.spring.io/libs-snapshot</url>
|
||||||
|
</repository>
|
||||||
|
----
|
||||||
|
|
||||||
|
== Getting Help
|
||||||
|
|
||||||
|
Having trouble with Spring Data? We’d love to help!
|
||||||
|
|
||||||
|
* Check the
|
||||||
|
https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/[reference documentation], and https://docs.spring.io/spring-data/elasticsearch/docs/current/api/[Javadocs].
|
||||||
|
* Learn the Spring basics – Spring Data builds on Spring Framework, check the https://spring.io[spring.io] web-site for a wealth of reference documentation.
|
||||||
|
If you are just starting out with Spring, try one of the https://spring.io/guides[guides].
|
||||||
|
* If you are upgrading, check out the https://docs.spring.io/spring-data/elasticsearch/docs/current/changelog.txt[changelog] for "`new and noteworthy`" features.
|
||||||
|
* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions tagged with https://stackoverflow.com/tags/spring-data[`spring-data-elasticsearch`].
|
||||||
|
You can also chat with the community on https://gitter.im/spring-projects/spring-data[Gitter].
|
||||||
|
* Report bugs with Spring Data for Elasticsearch at https://jira.spring.io/browse/DATAES[jira.spring.io/browse/DATAES].
|
||||||
|
|
||||||
|
== Reporting Issues
|
||||||
|
|
||||||
|
Spring Data uses JIRA as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:
|
||||||
|
|
||||||
|
* Before you log a bug, please search the
|
||||||
|
https://jira.spring.io/browse/DATAES[issue tracker] to see if someone has already reported the problem.
|
||||||
|
* If the issue doesn’t already exist, https://jira.spring.io/browse/DATAES[create a new issue].
|
||||||
|
* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using and JVM version.
|
||||||
|
* If you need to paste code, or include a stack trace use JIRA `{code}…{code}` escapes before and after your text.
|
||||||
|
* If possible try to create a test-case or project that replicates the issue. Attach a link to your code or a compressed file containing your code.
|
||||||
|
|
||||||
|
== Building from Source
|
||||||
|
|
||||||
|
You don’t need to build from source to use Spring Data (binaries in https://repo.spring.io[repo.spring.io]), but if you want to try out the latest and greatest, Spring Data can be easily built with the https://github.com/takari/maven-wrapper[maven wrapper].
|
||||||
|
You also need JDK 1.8.
|
||||||
|
|
||||||
|
[source,bash]
|
||||||
|
----
|
||||||
|
$ ./mvnw clean install
|
||||||
|
----
|
||||||
|
|
||||||
|
If you want to build with the regular `mvn` command, you will need https://maven.apache.org/run-maven/index.html[Maven v3.5.0 or above].
|
||||||
|
|
||||||
|
_Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests, and in particular please sign the https://cla.pivotal.io/sign/spring[Contributor’s Agreement] before your first non-trivial change._
|
||||||
|
|
||||||
|
=== Building reference documentation
|
||||||
|
|
||||||
|
Building the documentation builds also the project without running tests.
|
||||||
|
|
||||||
|
[source,bash]
|
||||||
|
----
|
||||||
|
$ ./mvnw clean install -Pdistribute
|
||||||
|
----
|
||||||
|
|
||||||
|
The generated documentation is available from `target/site/reference/html/index.html`.
|
||||||
|
|
||||||
|
== Examples
|
||||||
|
|
||||||
|
For examples on using the _Spring Data for Elasticsearch, see the https://github.com/SpringSource/spring-elasticsearch-examples[spring-elasticsearch-examples] project.
|
||||||
|
|
||||||
|
== License
|
||||||
|
|
||||||
|
Spring Data for Elasticsearch Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].
|
||||||
@@ -1,253 +0,0 @@
|
|||||||
Spring Data Elasticsearch
|
|
||||||
=========================
|
|
||||||
|
|
||||||
Spring Data implementation for ElasticSearch
|
|
||||||
|
|
||||||
Spring Data makes it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services as well as provide improved support for relational database technologies.
|
|
||||||
|
|
||||||
The Spring Data Elasticsearch project provides integration with the [elasticsearch](http://www.elasticsearch.org/) search engine.
|
|
||||||
|
|
||||||
Guide
|
|
||||||
------------
|
|
||||||
|
|
||||||
* [Reference Documentation](http://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/)
|
|
||||||
* [API Documentation](http://docs.spring.io/spring-data/elasticsearch/docs/current/api/)
|
|
||||||
* [Spring Data Project](http://projects.spring.io/spring-data)
|
|
||||||
* [Sample Test Application](https://github.com/BioMedCentralLtd/spring-data-elasticsearch-sample-application)
|
|
||||||
* [Issues](https://jira.springsource.org/browse/DATAES)
|
|
||||||
* [Spring Data Elasticsearch Google Group](https://groups.google.com/d/forum/spring-data-elasticsearch-devs)
|
|
||||||
* [Questions](http://stackoverflow.com/questions/tagged/spring-data-elasticsearch)
|
|
||||||
|
|
||||||
|
|
||||||
Quick Start
|
|
||||||
-----------
|
|
||||||
Wiki page for [Getting Started](https://github.com/spring-projects/spring-data-elasticsearch/wiki/How-to-start-with-spring-data-elasticsearch)
|
|
||||||
|
|
||||||
### Maven configuration
|
|
||||||
|
|
||||||
Add the Maven dependency:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-elasticsearch</artifactId>
|
|
||||||
<version>2.0.4.RELEASE</version>
|
|
||||||
</dependency>
|
|
||||||
```
|
|
||||||
|
|
||||||
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare
|
|
||||||
the appropriate dependency version.
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-elasticsearch</artifactId>
|
|
||||||
<version>2.1.0.BUILD-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>spring-libs-snapshot</id>
|
|
||||||
<name>Spring Snapshot Repository</name>
|
|
||||||
<url>http://repo.spring.io/libs-snapshot</url>
|
|
||||||
</repository>
|
|
||||||
```
|
|
||||||
|
|
||||||
| spring data elasticsearch | elasticsearch |
|
|
||||||
|:-----------------------------------:|:-------------:|
|
|
||||||
| 2.0.4.RELEASE | 2.4.0 |
|
|
||||||
| 2.0.0.RELEASE | 2.2.0 |
|
|
||||||
| 1.4.0.M1 | 1.7.3 |
|
|
||||||
| 1.3.0.RELEASE | 1.5.2 |
|
|
||||||
| 1.2.0.RELEASE | 1.4.4 |
|
|
||||||
| 1.1.0.RELEASE | 1.3.2 |
|
|
||||||
| 1.0.0.RELEASE | 1.1.1 |
|
|
||||||
|
|
||||||
|
|
||||||
### ElasticsearchRepository
|
|
||||||
A default implementation of ElasticsearchRepository, aligning to the generic Repository Interfaces, is provided. Spring can do the Repository implementation for you depending on method names in the interface definition.
|
|
||||||
|
|
||||||
The ElasticsearchCrudRepository extends PagingAndSortingRepository
|
|
||||||
|
|
||||||
```java
|
|
||||||
public interface ElasticsearchCrudRepository<T, ID extends Serializable> extends ElasticsearchRepository<T, ID>, PagingAndSortingRepository<T, ID> {
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Extending ElasticsearchRepository for custom methods
|
|
||||||
|
|
||||||
```java
|
|
||||||
public interface BookRepository extends Repository<Book, String> {
|
|
||||||
|
|
||||||
List<Book> findByNameAndPrice(String name, Integer price);
|
|
||||||
|
|
||||||
List<Book> findByNameOrPrice(String name, Integer price);
|
|
||||||
|
|
||||||
Page<Book> findByName(String name,Pageable page);
|
|
||||||
|
|
||||||
Page<Book> findByNameNot(String name,Pageable page);
|
|
||||||
|
|
||||||
Page<Book> findByPriceBetween(int price,Pageable page);
|
|
||||||
|
|
||||||
Page<Book> findByNameLike(String name,Pageable page);
|
|
||||||
|
|
||||||
@Query("{\"bool\" : {\"must\" : {\"term\" : {\"message\" : \"?0\"}}}}")
|
|
||||||
Page<Book> findByMessage(String message, Pageable pageable);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
Indexing a single document with Repository
|
|
||||||
|
|
||||||
```java
|
|
||||||
@Autowired
|
|
||||||
private SampleElasticsearchRepository repository;
|
|
||||||
|
|
||||||
String documentId = "123456";
|
|
||||||
SampleEntity sampleEntity = new SampleEntity();
|
|
||||||
sampleEntity.setId(documentId);
|
|
||||||
sampleEntity.setMessage("some message");
|
|
||||||
|
|
||||||
repository.save(sampleEntity);
|
|
||||||
```
|
|
||||||
|
|
||||||
Indexing multiple Document(bulk index) using Repository
|
|
||||||
|
|
||||||
```java
|
|
||||||
@Autowired
|
|
||||||
private SampleElasticsearchRepository repository;
|
|
||||||
|
|
||||||
String documentId = "123456";
|
|
||||||
SampleEntity sampleEntity1 = new SampleEntity();
|
|
||||||
sampleEntity1.setId(documentId);
|
|
||||||
sampleEntity1.setMessage("some message");
|
|
||||||
|
|
||||||
String documentId2 = "123457"
|
|
||||||
SampleEntity sampleEntity2 = new SampleEntity();
|
|
||||||
sampleEntity2.setId(documentId2);
|
|
||||||
sampleEntity2.setMessage("test message");
|
|
||||||
|
|
||||||
List<SampleEntity> sampleEntities = Arrays.asList(sampleEntity1, sampleEntity2);
|
|
||||||
|
|
||||||
//bulk index
|
|
||||||
repository.save(sampleEntities);
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### ElasticsearchTemplate
|
|
||||||
|
|
||||||
ElasticsearchTemplate is the central support class for elasticsearch operations.
|
|
||||||
|
|
||||||
Indexing a single document using Elasticsearch Template
|
|
||||||
|
|
||||||
```java
|
|
||||||
String documentId = "123456";
|
|
||||||
SampleEntity sampleEntity = new SampleEntity();
|
|
||||||
sampleEntity.setId(documentId);
|
|
||||||
sampleEntity.setMessage("some message");
|
|
||||||
IndexQuery indexQuery = new IndexQueryBuilder().withId(sampleEntity.getId()).withObject(sampleEntity).build();
|
|
||||||
elasticsearchTemplate.index(indexQuery);
|
|
||||||
```
|
|
||||||
|
|
||||||
Indexing multiple Document(bulk index) using Elasticsearch Template
|
|
||||||
|
|
||||||
```java
|
|
||||||
@Autowired
|
|
||||||
private ElasticsearchTemplate elasticsearchTemplate;
|
|
||||||
|
|
||||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
|
||||||
//first document
|
|
||||||
String documentId = "123456";
|
|
||||||
SampleEntity sampleEntity1 = new SampleEntity();
|
|
||||||
sampleEntity1.setId(documentId);
|
|
||||||
sampleEntity1.setMessage("some message");
|
|
||||||
|
|
||||||
IndexQuery indexQuery1 = new IndexQueryBuilder().withId(sampleEntity1.getId()).withObject(sampleEntity1).build();
|
|
||||||
indexQueries.add(indexQuery1);
|
|
||||||
|
|
||||||
//second document
|
|
||||||
String documentId2 = "123457";
|
|
||||||
SampleEntity sampleEntity2 = new SampleEntity();
|
|
||||||
sampleEntity2.setId(documentId2);
|
|
||||||
sampleEntity2.setMessage("some message");
|
|
||||||
|
|
||||||
IndexQuery indexQuery2 = new IndexQueryBuilder().withId(sampleEntity2.getId()).withObject(sampleEntity2).build()
|
|
||||||
indexQueries.add(indexQuery2);
|
|
||||||
|
|
||||||
//bulk index
|
|
||||||
elasticsearchTemplate.bulkIndex(indexQueries);
|
|
||||||
```
|
|
||||||
|
|
||||||
Searching entities using Elasticsearch Template
|
|
||||||
|
|
||||||
```java
|
|
||||||
@Autowired
|
|
||||||
private ElasticsearchTemplate elasticsearchTemplate;
|
|
||||||
|
|
||||||
SearchQuery searchQuery = new NativeSearchQueryBuilder()
|
|
||||||
.withQuery(queryString(documentId).field("id"))
|
|
||||||
.build();
|
|
||||||
Page<SampleEntity> sampleEntities = elasticsearchTemplate.queryForPage(searchQuery,SampleEntity.class);
|
|
||||||
```
|
|
||||||
|
|
||||||
### XML Namespace
|
|
||||||
|
|
||||||
You can set up repository scanning via xml configuration, which will happily create your repositories.
|
|
||||||
|
|
||||||
Using Node Client
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<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.xsd
|
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
|
||||||
|
|
||||||
<elasticsearch:node-client id="client" local="true"/>
|
|
||||||
|
|
||||||
<bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
|
|
||||||
<constructor-arg name="client" ref="client"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
</beans>
|
|
||||||
```
|
|
||||||
|
|
||||||
Using Transport Client
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<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.xsd
|
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
|
||||||
|
|
||||||
<elasticsearch:repositories base-package="com.xyz.acme"/>
|
|
||||||
|
|
||||||
<elasticsearch:transport-client id="client" cluster-nodes="ip:9300,ip:9300" cluster-name="elasticsearch" />
|
|
||||||
|
|
||||||
<bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
|
|
||||||
<constructor-arg name="client" ref="client"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
</beans>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Help Pages
|
|
||||||
|
|
||||||
* [Geo distance and location search](https://github.com/spring-projects/spring-data-elasticsearch/wiki/Geo-indexing-and-request)
|
|
||||||
* [Custom object mapper](https://github.com/spring-projects/spring-data-elasticsearch/wiki/Custom-ObjectMapper)
|
|
||||||
|
|
||||||
## Contributing to Spring Data
|
|
||||||
|
|
||||||
Here are some ways for you to get involved in the community:
|
|
||||||
|
|
||||||
* Get involved with the Spring community on the Spring Community Forums. Please help out on the [forum](http://forum.springsource.org/forumdisplay.php?f=80) by responding to questions and joining the debate.
|
|
||||||
* Create [JIRA](https://jira.springframework.org/browse/DATAES) tickets for bugs and new features and comment and vote on the ones that you are interested in.
|
|
||||||
* Github is for social coding: if you want to write code, we encourage contributions through pull requests from [forks of this repository](http://help.github.com/forking/). If you want to contribute code this way, please reference a JIRA ticket as well covering the specific issue you are addressing.
|
|
||||||
* Watch for upcoming articles on Spring by [subscribing](http://www.springsource.org/node/feed) to springframework.org
|
|
||||||
|
|
||||||
Before we accept a non-trivial patch or pull request we will need you to sign the [contributor's agreement](https://support.springsource.com/spring_committer_signup). Signing the contributor's agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. Active contributors might be asked to join the core team, and given the ability to merge pull requests.
|
|
||||||
|
|
||||||
|
|
||||||
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.adoc)
|
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Maven2 Start Up Batch script
|
||||||
|
#
|
||||||
|
# Required ENV vars:
|
||||||
|
# ------------------
|
||||||
|
# JAVA_HOME - location of a JDK home dir
|
||||||
|
#
|
||||||
|
# Optional ENV vars
|
||||||
|
# -----------------
|
||||||
|
# M2_HOME - location of maven2's installed home dir
|
||||||
|
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
# e.g. to debug Maven itself, use
|
||||||
|
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||||
|
|
||||||
|
if [ -f /etc/mavenrc ] ; then
|
||||||
|
. /etc/mavenrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$HOME/.mavenrc" ] ; then
|
||||||
|
. "$HOME/.mavenrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# OS specific support. $var _must_ be set to either true or false.
|
||||||
|
cygwin=false;
|
||||||
|
darwin=false;
|
||||||
|
mingw=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN*) cygwin=true ;;
|
||||||
|
MINGW*) mingw=true;;
|
||||||
|
Darwin*) darwin=true
|
||||||
|
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||||
|
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
if [ -x "/usr/libexec/java_home" ]; then
|
||||||
|
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||||
|
else
|
||||||
|
export JAVA_HOME="/Library/Java/Home"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
if [ -r /etc/gentoo-release ] ; then
|
||||||
|
JAVA_HOME=`java-config --jre-home`
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$M2_HOME" ] ; then
|
||||||
|
## resolve links - $0 may be a link to maven's home
|
||||||
|
PRG="$0"
|
||||||
|
|
||||||
|
# need this for relative symlinks
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG="`dirname "$PRG"`/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
saveddir=`pwd`
|
||||||
|
|
||||||
|
M2_HOME=`dirname "$PRG"`/..
|
||||||
|
|
||||||
|
# make it fully qualified
|
||||||
|
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||||
|
|
||||||
|
cd "$saveddir"
|
||||||
|
# echo Using m2 at $M2_HOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $cygwin ; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $mingw ; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||||
|
# TODO classpath?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
javaExecutable="`which javac`"
|
||||||
|
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||||
|
# readlink(1) is not available as standard on Solaris 10.
|
||||||
|
readLink=`which readlink`
|
||||||
|
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||||
|
if $darwin ; then
|
||||||
|
javaHome="`dirname \"$javaExecutable\"`"
|
||||||
|
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||||
|
else
|
||||||
|
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||||
|
fi
|
||||||
|
javaHome="`dirname \"$javaExecutable\"`"
|
||||||
|
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||||
|
JAVA_HOME="$javaHome"
|
||||||
|
export JAVA_HOME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVACMD" ] ; then
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="`which java`"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||||
|
echo " We cannot execute $JAVACMD" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
echo "Warning: JAVA_HOME environment variable is not set."
|
||||||
|
fi
|
||||||
|
|
||||||
|
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||||
|
|
||||||
|
# traverses directory structure from process work directory to filesystem root
|
||||||
|
# first directory with .mvn subdirectory is considered project base directory
|
||||||
|
find_maven_basedir() {
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "Path not specified to find_maven_basedir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
basedir="$1"
|
||||||
|
wdir="$1"
|
||||||
|
while [ "$wdir" != '/' ] ; do
|
||||||
|
if [ -d "$wdir"/.mvn ] ; then
|
||||||
|
basedir=$wdir
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||||
|
if [ -d "${wdir}" ]; then
|
||||||
|
wdir=`cd "$wdir/.."; pwd`
|
||||||
|
fi
|
||||||
|
# end of workaround
|
||||||
|
done
|
||||||
|
echo "${basedir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# concatenates all lines of a file
|
||||||
|
concat_lines() {
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
echo "$(tr -s '\n' ' ' < "$1")"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||||
|
if [ -z "$BASE_DIR" ]; then
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||||
|
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||||
|
##########################################################################################
|
||||||
|
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||||
|
fi
|
||||||
|
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||||
|
while IFS="=" read key value; do
|
||||||
|
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||||
|
esac
|
||||||
|
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Downloading from: $jarUrl"
|
||||||
|
fi
|
||||||
|
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||||
|
|
||||||
|
if command -v wget > /dev/null; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Found wget ... using wget"
|
||||||
|
fi
|
||||||
|
wget "$jarUrl" -O "$wrapperJarPath"
|
||||||
|
elif command -v curl > /dev/null; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Found curl ... using curl"
|
||||||
|
fi
|
||||||
|
curl -o "$wrapperJarPath" "$jarUrl"
|
||||||
|
else
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Falling back to using Java to download"
|
||||||
|
fi
|
||||||
|
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||||
|
if [ -e "$javaClass" ]; then
|
||||||
|
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||||
|
fi
|
||||||
|
# Compiling the Java class
|
||||||
|
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||||
|
fi
|
||||||
|
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||||
|
# Running the downloader
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo " - Running MavenWrapperDownloader.java ..."
|
||||||
|
fi
|
||||||
|
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
##########################################################################################
|
||||||
|
# End of extension
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo $MAVEN_PROJECTBASEDIR
|
||||||
|
fi
|
||||||
|
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||||
|
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||||
|
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
exec "$JAVACMD" \
|
||||||
|
$MAVEN_OPTS \
|
||||||
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
|
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@REM or more contributor license agreements. See the NOTICE file
|
||||||
|
@REM distributed with this work for additional information
|
||||||
|
@REM regarding copyright ownership. The ASF licenses this file
|
||||||
|
@REM to you under the Apache License, Version 2.0 (the
|
||||||
|
@REM "License"); you may not use this file except in compliance
|
||||||
|
@REM with the License. You may obtain a copy of the License at
|
||||||
|
@REM
|
||||||
|
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@REM
|
||||||
|
@REM Unless required by applicable law or agreed to in writing,
|
||||||
|
@REM software distributed under the License is distributed on an
|
||||||
|
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
@REM KIND, either express or implied. See the License for the
|
||||||
|
@REM specific language governing permissions and limitations
|
||||||
|
@REM under the License.
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Maven2 Start Up Batch script
|
||||||
|
@REM
|
||||||
|
@REM Required ENV vars:
|
||||||
|
@REM JAVA_HOME - location of a JDK home dir
|
||||||
|
@REM
|
||||||
|
@REM Optional ENV vars
|
||||||
|
@REM M2_HOME - location of maven2's installed home dir
|
||||||
|
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||||
|
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||||
|
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
@REM e.g. to debug Maven itself, use
|
||||||
|
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||||
|
@echo off
|
||||||
|
@REM set title of command window
|
||||||
|
title %0
|
||||||
|
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||||
|
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||||
|
|
||||||
|
@REM set %HOME% to equivalent of $HOME
|
||||||
|
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||||
|
|
||||||
|
@REM Execute a user defined script before this one
|
||||||
|
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||||
|
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||||
|
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||||
|
:skipRcPre
|
||||||
|
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
set ERROR_CODE=0
|
||||||
|
|
||||||
|
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
@REM ==== START VALIDATION ====
|
||||||
|
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME not found in your environment. >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
:OkJHome
|
||||||
|
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||||
|
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
@REM ==== END VALIDATION ====
|
||||||
|
|
||||||
|
:init
|
||||||
|
|
||||||
|
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||||
|
@REM Fallback to current working directory if not found.
|
||||||
|
|
||||||
|
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||||
|
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||||
|
|
||||||
|
set EXEC_DIR=%CD%
|
||||||
|
set WDIR=%EXEC_DIR%
|
||||||
|
:findBaseDir
|
||||||
|
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||||
|
cd ..
|
||||||
|
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||||
|
set WDIR=%CD%
|
||||||
|
goto findBaseDir
|
||||||
|
|
||||||
|
:baseDirFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
goto endDetectBaseDir
|
||||||
|
|
||||||
|
:baseDirNotFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
|
||||||
|
:endDetectBaseDir
|
||||||
|
|
||||||
|
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||||
|
|
||||||
|
@setlocal EnableExtensions EnableDelayedExpansion
|
||||||
|
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||||
|
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||||
|
|
||||||
|
:endReadAdditionalConfig
|
||||||
|
|
||||||
|
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||||
|
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||||
|
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||||
|
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
|
||||||
|
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||||
|
)
|
||||||
|
|
||||||
|
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||||
|
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||||
|
if exist %WRAPPER_JAR% (
|
||||||
|
echo Found %WRAPPER_JAR%
|
||||||
|
) else (
|
||||||
|
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||||
|
echo Downloading from: %DOWNLOAD_URL%
|
||||||
|
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
|
||||||
|
echo Finished downloading %WRAPPER_JAR%
|
||||||
|
)
|
||||||
|
@REM End of extension
|
||||||
|
|
||||||
|
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||||
|
if ERRORLEVEL 1 goto error
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:error
|
||||||
|
set ERROR_CODE=1
|
||||||
|
|
||||||
|
:end
|
||||||
|
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||||
|
|
||||||
|
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||||
|
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||||
|
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||||
|
:skipRcPost
|
||||||
|
|
||||||
|
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||||
|
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||||
|
|
||||||
|
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||||
|
|
||||||
|
exit /B %ERROR_CODE%
|
||||||
@@ -1,208 +1,221 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-elasticsearch</artifactId>
|
<artifactId>spring-data-elasticsearch</artifactId>
|
||||||
<version>2.1.0.BUILD-SNAPSHOT</version>
|
<version>2.1.23.RELEASE</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data.build</groupId>
|
<groupId>org.springframework.data.build</groupId>
|
||||||
<artifactId>spring-data-parent</artifactId>
|
<artifactId>spring-data-parent</artifactId>
|
||||||
<version>1.9.0.BUILD-SNAPSHOT</version>
|
<version>1.9.23.RELEASE</version>
|
||||||
<relativePath>../spring-data-build/parent/pom.xml</relativePath>
|
<relativePath>../spring-data-build/parent/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<name>Spring Data Elasticsearch</name>
|
<name>Spring Data Elasticsearch</name>
|
||||||
<description>Spring Data Implementation for Elasticsearch</description>
|
<description>Spring Data Implementation for Elasticsearch</description>
|
||||||
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
||||||
<dist.key>DATAES</dist.key>
|
<dist.key>DATAES</dist.key>
|
||||||
|
|
||||||
<commonscollections>3.2.1</commonscollections>
|
<commonscollections>3.2.1</commonscollections>
|
||||||
<commonslang>2.6</commonslang>
|
<commonslang>2.6</commonslang>
|
||||||
<elasticsearch>2.4.0</elasticsearch>
|
<elasticsearch>2.4.0</elasticsearch>
|
||||||
<springdata.commons>1.13.0.BUILD-SNAPSHOT</springdata.commons>
|
<springdata.commons>1.13.23.RELEASE</springdata.commons>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context</artifactId>
|
<artifactId>spring-context</artifactId>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>commons-logging</groupId>
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-tx</artifactId>
|
<artifactId>spring-tx</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SPRING DATA -->
|
<!-- SPRING DATA -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-commons</artifactId>
|
<artifactId>spring-data-commons</artifactId>
|
||||||
<version>${springdata.commons}</version>
|
<version>${springdata.commons}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- APACHE -->
|
<!-- APACHE -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-lang</groupId>
|
<groupId>commons-lang</groupId>
|
||||||
<artifactId>commons-lang</artifactId>
|
<artifactId>commons-lang</artifactId>
|
||||||
<version>${commonslang}</version>
|
<version>${commonslang}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JODA Time -->
|
<!-- JODA Time -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>joda-time</artifactId>
|
||||||
<version>${jodatime}</version>
|
<version>${jodatime}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Elasticsearch -->
|
<!-- Elasticsearch -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.elasticsearch</groupId>
|
<groupId>org.elasticsearch</groupId>
|
||||||
<artifactId>elasticsearch</artifactId>
|
<artifactId>elasticsearch</artifactId>
|
||||||
<version>${elasticsearch}</version>
|
<version>${elasticsearch}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Jackson JSON Mapper -->
|
<!-- Jackson JSON Mapper -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>${jackson}</version>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
<dependency>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
</dependency>
|
||||||
<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 -->
|
<!-- CDI -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>javax.enterprise</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>cdi-api</artifactId>
|
||||||
<scope>test</scope>
|
<version>${cdi}</version>
|
||||||
</dependency>
|
<scope>provided</scope>
|
||||||
<dependency>
|
<optional>true</optional>
|
||||||
<groupId>org.apache.openwebbeans.test</groupId>
|
</dependency>
|
||||||
<artifactId>cditest-owb</artifactId>
|
|
||||||
<version>${webbeans}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
|
||||||
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
|
||||||
<artifactId>geronimo-atinject_1.0_spec</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
<version>3.0-alpha-1</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<!-- Test -->
|
||||||
<groupId>org.projectlombok</groupId>
|
<dependency>
|
||||||
<artifactId>lombok</artifactId>
|
<groupId>org.springframework</groupId>
|
||||||
<version>${lombok}</version>
|
<artifactId>spring-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.openwebbeans.test</groupId>
|
||||||
|
<artifactId>cditest-owb</artifactId>
|
||||||
|
<version>${webbeans}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
|
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
|
<artifactId>geronimo-atinject_1.0_spec</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
<version>3.0-alpha-1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<build>
|
</dependencies>
|
||||||
<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>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.asciidoctor</groupId>
|
|
||||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<profiles>
|
<build>
|
||||||
<profile>
|
<plugins>
|
||||||
<id>release</id>
|
<plugin>
|
||||||
<build>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<plugins>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<plugin>
|
</plugin>
|
||||||
<groupId>org.jfrog.buildinfo</groupId>
|
<plugin>
|
||||||
<artifactId>artifactory-maven-plugin</artifactId>
|
<groupId>org.asciidoctor</groupId>
|
||||||
<inherited>false</inherited>
|
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<developers>
|
<profiles>
|
||||||
<developer>
|
<profile>
|
||||||
<id>biomedcentral</id>
|
|
||||||
<name>BioMed Central Development Team</name>
|
|
||||||
<timezone>+0</timezone>
|
|
||||||
</developer>
|
|
||||||
</developers>
|
|
||||||
|
|
||||||
<repositories>
|
<id>ci</id>
|
||||||
<repository>
|
|
||||||
<id>spring-libs-snapshot</id>
|
|
||||||
<url>https://repo.spring.io/libs-snapshot</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
<build>
|
||||||
<pluginRepository>
|
<plugins>
|
||||||
<id>spring-plugins-release</id>
|
<plugin>
|
||||||
<url>https://repo.spring.io/plugins-release</url>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
</pluginRepository>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
</pluginRepositories>
|
<configuration>
|
||||||
|
<checkstyleRules>
|
||||||
|
<module name="Checker">
|
||||||
|
|
||||||
<scm>
|
<!-- Configure checker to use UTF-8 encoding -->
|
||||||
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
<property name="charset" value="UTF-8"/>
|
||||||
<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>
|
<module name="io.spring.nohttp.checkstyle.check.NoHttpCheck"/>
|
||||||
<system>Bamboo</system>
|
</module>
|
||||||
<url>http://build.springsource.org/browse/SPRINGDATAES</url>
|
</checkstyleRules>
|
||||||
</ciManagement>
|
<includes>**/*</includes>
|
||||||
|
<excludes>
|
||||||
|
.git/**/*,target/**/*,**/target/**/*,.idea/**/*,**/spring.schemas,**/*.svg,mvnw,mvnw.cmd,**/*.policy
|
||||||
|
</excludes>
|
||||||
|
<sourceDirectories>./</sourceDirectories>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<issueManagement>
|
</profile>
|
||||||
<system>JIRA</system>
|
|
||||||
<url>https://jira.springsource.org/browse/DATAES</url>
|
</profiles>
|
||||||
</issueManagement>
|
|
||||||
|
<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>https://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>https://build.springsource.org/browse/SPRINGDATAES</url>
|
||||||
|
</ciManagement>
|
||||||
|
|
||||||
|
<issueManagement>
|
||||||
|
<system>JIRA</system>
|
||||||
|
<url>https://jira.springsource.org/browse/DATAES</url>
|
||||||
|
</issueManagement>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ BioMed Central Development Team
|
|||||||
:toc-placement!:
|
:toc-placement!:
|
||||||
:spring-data-commons-docs: ../../../../spring-data-commons/src/main/asciidoc
|
:spring-data-commons-docs: ../../../../spring-data-commons/src/main/asciidoc
|
||||||
|
|
||||||
(C) 2013-2015 The original author(s).
|
(C) 2013-2019 The original author(s).
|
||||||
|
|
||||||
NOTE: 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.
|
NOTE: 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.
|
||||||
|
|
||||||
|
|||||||
@@ -1,51 +1,51 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchException
|
* ElasticsearchException
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class ElasticsearchException extends RuntimeException {
|
public class ElasticsearchException extends RuntimeException {
|
||||||
|
|
||||||
private Map<String, String> failedDocuments;
|
private Map<String, String> failedDocuments;
|
||||||
|
|
||||||
public ElasticsearchException(String message) {
|
public ElasticsearchException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElasticsearchException(String message, Throwable cause) {
|
public ElasticsearchException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElasticsearchException(String message, Throwable cause, Map<String, String> failedDocuments) {
|
public ElasticsearchException(String message, Throwable cause, Map<String, String> failedDocuments) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
this.failedDocuments = failedDocuments;
|
this.failedDocuments = failedDocuments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElasticsearchException(String message, Map<String, String> failedDocuments) {
|
public ElasticsearchException(String message, Map<String, String> failedDocuments) {
|
||||||
super(message);
|
super(message);
|
||||||
this.failedDocuments = failedDocuments;
|
this.failedDocuments = failedDocuments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getFailedDocuments() {
|
public Map<String, String> getFailedDocuments() {
|
||||||
return failedDocuments;
|
return failedDocuments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,51 +1,51 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.annotations;
|
package org.springframework.data.elasticsearch.annotations;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Persistent;
|
import org.springframework.data.annotation.Persistent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document
|
* Document
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Mason Chan
|
* @author Mason Chan
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Persistent
|
@Persistent
|
||||||
@Inherited
|
@Inherited
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.TYPE})
|
@Target({ElementType.TYPE})
|
||||||
public @interface Document {
|
public @interface Document {
|
||||||
|
|
||||||
String indexName();
|
String indexName();
|
||||||
|
|
||||||
String type() default "";
|
String type() default "";
|
||||||
|
|
||||||
boolean useServerConfiguration() default false;
|
boolean useServerConfiguration() default false;
|
||||||
|
|
||||||
short shards() default 5;
|
short shards() default 5;
|
||||||
|
|
||||||
short replicas() default 1;
|
short replicas() default 1;
|
||||||
|
|
||||||
String refreshInterval() default "1s";
|
String refreshInterval() default "1s";
|
||||||
|
|
||||||
String indexStoreType() default "fs";
|
String indexStoreType() default "fs";
|
||||||
|
|
||||||
boolean createIndex() default true;
|
boolean createIndex() default true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +1,56 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.annotations;
|
package org.springframework.data.elasticsearch.annotations;
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Inherited;
|
import java.lang.annotation.Inherited;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Jonathan Yan
|
* @author Jonathan Yan
|
||||||
* @author Jakub Vavrik
|
* @author Jakub Vavrik
|
||||||
* @author Kevin Leturc
|
* @author Kevin Leturc
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
@Documented
|
@Documented
|
||||||
@Inherited
|
@Inherited
|
||||||
public @interface Field {
|
public @interface Field {
|
||||||
|
|
||||||
FieldType type() default FieldType.Auto;
|
FieldType type() default FieldType.Auto;
|
||||||
|
|
||||||
FieldIndex index() default FieldIndex.analyzed;
|
FieldIndex index() default FieldIndex.analyzed;
|
||||||
|
|
||||||
DateFormat format() default DateFormat.none;
|
DateFormat format() default DateFormat.none;
|
||||||
|
|
||||||
String pattern() default "";
|
String pattern() default "";
|
||||||
|
|
||||||
boolean store() default false;
|
boolean store() default false;
|
||||||
|
|
||||||
String searchAnalyzer() default "";
|
String searchAnalyzer() default "";
|
||||||
|
|
||||||
String analyzer() default "";
|
String analyzer() default "";
|
||||||
|
|
||||||
String[] ignoreFields() default {};
|
String[] ignoreFields() default {};
|
||||||
|
|
||||||
boolean includeInParent() default false;
|
boolean includeInParent() default false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,45 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.annotations;
|
package org.springframework.data.elasticsearch.annotations;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query
|
* Query
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface Query {
|
public @interface Query {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elasticsearch query to be used when executing query. May contain placeholders eg. ?0
|
* Elasticsearch query to be used when executing query. May contain placeholders eg. ?0
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String value() default "";
|
String value() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Named Query Named looked up by repository.
|
* Named Query Named looked up by repository.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String name() default "";
|
String name() default "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+127
-127
@@ -1,127 +1,127 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015 the original author or authors.
|
* Copyright 2015-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.client;
|
package org.springframework.data.elasticsearch.client;
|
||||||
|
|
||||||
import static org.elasticsearch.node.NodeBuilder.*;
|
import static org.elasticsearch.node.NodeBuilder.*;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NodeClientFactoryBean
|
* NodeClientFactoryBean
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class NodeClientFactoryBean implements FactoryBean<NodeClient>, InitializingBean, DisposableBean {
|
public class NodeClientFactoryBean implements FactoryBean<NodeClient>, InitializingBean, DisposableBean {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(NodeClientFactoryBean.class);
|
private static final Logger logger = LoggerFactory.getLogger(NodeClientFactoryBean.class);
|
||||||
private boolean local;
|
private boolean local;
|
||||||
private boolean enableHttp;
|
private boolean enableHttp;
|
||||||
private String clusterName;
|
private String clusterName;
|
||||||
private NodeClient nodeClient;
|
private NodeClient nodeClient;
|
||||||
private String pathData;
|
private String pathData;
|
||||||
private String pathHome;
|
private String pathHome;
|
||||||
private String pathConfiguration;
|
private String pathConfiguration;
|
||||||
|
|
||||||
NodeClientFactoryBean() {
|
NodeClientFactoryBean() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeClientFactoryBean(boolean local) {
|
public NodeClientFactoryBean(boolean local) {
|
||||||
this.local = local;
|
this.local = local;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeClient getObject() throws Exception {
|
public NodeClient getObject() throws Exception {
|
||||||
return nodeClient;
|
return nodeClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Client> getObjectType() {
|
public Class<? extends Client> getObjectType() {
|
||||||
return NodeClient.class;
|
return NodeClient.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSingleton() {
|
public boolean isSingleton() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
nodeClient = (NodeClient) nodeBuilder().settings(Settings.builder().put(loadConfig())
|
nodeClient = (NodeClient) nodeBuilder().settings(Settings.builder().put(loadConfig())
|
||||||
.put("http.enabled", String.valueOf(this.enableHttp))
|
.put("http.enabled", String.valueOf(this.enableHttp))
|
||||||
.put("path.home", this.pathHome)
|
.put("path.home", this.pathHome)
|
||||||
.put("path.data", this.pathData))
|
.put("path.data", this.pathData))
|
||||||
.clusterName(this.clusterName).local(this.local).node()
|
.clusterName(this.clusterName).local(this.local).node()
|
||||||
.client();
|
.client();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Settings loadConfig() {
|
private Settings loadConfig() {
|
||||||
if (StringUtils.isNotBlank(pathConfiguration)) {
|
if (StringUtils.isNotBlank(pathConfiguration)) {
|
||||||
InputStream stream = getClass().getClassLoader().getResourceAsStream(pathConfiguration);
|
InputStream stream = getClass().getClassLoader().getResourceAsStream(pathConfiguration);
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
return Settings.builder().loadFromStream(pathConfiguration, getClass().getClassLoader().getResourceAsStream(pathConfiguration)).build();
|
return Settings.builder().loadFromStream(pathConfiguration, getClass().getClassLoader().getResourceAsStream(pathConfiguration)).build();
|
||||||
}
|
}
|
||||||
logger.error(String.format("Unable to read node configuration from file [%s]", pathConfiguration));
|
logger.error(String.format("Unable to read node configuration from file [%s]", pathConfiguration));
|
||||||
}
|
}
|
||||||
return Settings.builder().build();
|
return Settings.builder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocal(boolean local) {
|
public void setLocal(boolean local) {
|
||||||
this.local = local;
|
this.local = local;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnableHttp(boolean enableHttp) {
|
public void setEnableHttp(boolean enableHttp) {
|
||||||
this.enableHttp = enableHttp;
|
this.enableHttp = enableHttp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClusterName(String clusterName) {
|
public void setClusterName(String clusterName) {
|
||||||
this.clusterName = clusterName;
|
this.clusterName = clusterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPathData(String pathData) {
|
public void setPathData(String pathData) {
|
||||||
this.pathData = pathData;
|
this.pathData = pathData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPathHome(String pathHome) {
|
public void setPathHome(String pathHome) {
|
||||||
this.pathHome = pathHome;
|
this.pathHome = pathHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPathConfiguration(String configuration) {
|
public void setPathConfiguration(String configuration) {
|
||||||
this.pathConfiguration = configuration;
|
this.pathConfiguration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
try {
|
try {
|
||||||
logger.info("Closing elasticSearch client");
|
logger.info("Closing elasticSearch client");
|
||||||
if (nodeClient != null) {
|
if (nodeClient != null) {
|
||||||
nodeClient.close();
|
nodeClient.close();
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
logger.error("Error closing ElasticSearch client: ", e);
|
logger.error("Error closing ElasticSearch client: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+154
-154
@@ -1,154 +1,154 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.client;
|
package org.springframework.data.elasticsearch.client;
|
||||||
|
|
||||||
import static org.apache.commons.lang.StringUtils.*;
|
import static org.apache.commons.lang.StringUtils.*;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TransportClientFactoryBean
|
* TransportClientFactoryBean
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Jakub Vavrik
|
* @author Jakub Vavrik
|
||||||
* @author Piotr Betkier
|
* @author Piotr Betkier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TransportClientFactoryBean implements FactoryBean<TransportClient>, InitializingBean, DisposableBean {
|
public class TransportClientFactoryBean implements FactoryBean<TransportClient>, InitializingBean, DisposableBean {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TransportClientFactoryBean.class);
|
private static final Logger logger = LoggerFactory.getLogger(TransportClientFactoryBean.class);
|
||||||
private String clusterNodes = "127.0.0.1:9300";
|
private String clusterNodes = "127.0.0.1:9300";
|
||||||
private String clusterName = "elasticsearch";
|
private String clusterName = "elasticsearch";
|
||||||
private Boolean clientTransportSniff = true;
|
private Boolean clientTransportSniff = true;
|
||||||
private Boolean clientIgnoreClusterName = Boolean.FALSE;
|
private Boolean clientIgnoreClusterName = Boolean.FALSE;
|
||||||
private String clientPingTimeout = "5s";
|
private String clientPingTimeout = "5s";
|
||||||
private String clientNodesSamplerInterval = "5s";
|
private String clientNodesSamplerInterval = "5s";
|
||||||
private TransportClient client;
|
private TransportClient client;
|
||||||
private Properties properties;
|
private Properties properties;
|
||||||
static final String COLON = ":";
|
static final String COLON = ":";
|
||||||
static final String COMMA = ",";
|
static final String COMMA = ",";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
try {
|
try {
|
||||||
logger.info("Closing elasticSearch client");
|
logger.info("Closing elasticSearch client");
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
client.close();
|
client.close();
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
logger.error("Error closing ElasticSearch client: ", e);
|
logger.error("Error closing ElasticSearch client: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransportClient getObject() throws Exception {
|
public TransportClient getObject() throws Exception {
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<TransportClient> getObjectType() {
|
public Class<TransportClient> getObjectType() {
|
||||||
return TransportClient.class;
|
return TransportClient.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSingleton() {
|
public boolean isSingleton() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
buildClient();
|
buildClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void buildClient() throws Exception {
|
protected void buildClient() throws Exception {
|
||||||
client = TransportClient.builder().settings(settings()).build();
|
client = TransportClient.builder().settings(settings()).build();
|
||||||
Assert.hasText(clusterNodes, "[Assertion failed] clusterNodes settings missing.");
|
Assert.hasText(clusterNodes, "[Assertion failed] clusterNodes settings missing.");
|
||||||
for (String clusterNode : split(clusterNodes, COMMA)) {
|
for (String clusterNode : split(clusterNodes, COMMA)) {
|
||||||
String hostName = substringBeforeLast(clusterNode, COLON);
|
String hostName = substringBeforeLast(clusterNode, COLON);
|
||||||
String port = substringAfterLast(clusterNode, COLON);
|
String port = substringAfterLast(clusterNode, COLON);
|
||||||
Assert.hasText(hostName, "[Assertion failed] missing host name in 'clusterNodes'");
|
Assert.hasText(hostName, "[Assertion failed] missing host name in 'clusterNodes'");
|
||||||
Assert.hasText(port, "[Assertion failed] missing port in 'clusterNodes'");
|
Assert.hasText(port, "[Assertion failed] missing port in 'clusterNodes'");
|
||||||
logger.info("adding transport node : " + clusterNode);
|
logger.info("adding transport node : " + clusterNode);
|
||||||
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostName), Integer.valueOf(port)));
|
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostName), Integer.valueOf(port)));
|
||||||
}
|
}
|
||||||
client.connectedNodes();
|
client.connectedNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Settings settings() {
|
private Settings settings() {
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
return Settings.builder().put(properties).build();
|
return Settings.builder().put(properties).build();
|
||||||
}
|
}
|
||||||
return Settings.builder()
|
return Settings.builder()
|
||||||
.put("cluster.name", clusterName)
|
.put("cluster.name", clusterName)
|
||||||
.put("client.transport.sniff", clientTransportSniff)
|
.put("client.transport.sniff", clientTransportSniff)
|
||||||
.put("client.transport.ignore_cluster_name", clientIgnoreClusterName)
|
.put("client.transport.ignore_cluster_name", clientIgnoreClusterName)
|
||||||
.put("client.transport.ping_timeout", clientPingTimeout)
|
.put("client.transport.ping_timeout", clientPingTimeout)
|
||||||
.put("client.transport.nodes_sampler_interval", clientNodesSamplerInterval)
|
.put("client.transport.nodes_sampler_interval", clientNodesSamplerInterval)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClusterNodes(String clusterNodes) {
|
public void setClusterNodes(String clusterNodes) {
|
||||||
this.clusterNodes = clusterNodes;
|
this.clusterNodes = clusterNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClusterName(String clusterName) {
|
public void setClusterName(String clusterName) {
|
||||||
this.clusterName = clusterName;
|
this.clusterName = clusterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClientTransportSniff(Boolean clientTransportSniff) {
|
public void setClientTransportSniff(Boolean clientTransportSniff) {
|
||||||
this.clientTransportSniff = clientTransportSniff;
|
this.clientTransportSniff = clientTransportSniff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClientNodesSamplerInterval() {
|
public String getClientNodesSamplerInterval() {
|
||||||
return clientNodesSamplerInterval;
|
return clientNodesSamplerInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClientNodesSamplerInterval(String clientNodesSamplerInterval) {
|
public void setClientNodesSamplerInterval(String clientNodesSamplerInterval) {
|
||||||
this.clientNodesSamplerInterval = clientNodesSamplerInterval;
|
this.clientNodesSamplerInterval = clientNodesSamplerInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClientPingTimeout() {
|
public String getClientPingTimeout() {
|
||||||
return clientPingTimeout;
|
return clientPingTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClientPingTimeout(String clientPingTimeout) {
|
public void setClientPingTimeout(String clientPingTimeout) {
|
||||||
this.clientPingTimeout = clientPingTimeout;
|
this.clientPingTimeout = clientPingTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getClientIgnoreClusterName() {
|
public Boolean getClientIgnoreClusterName() {
|
||||||
return clientIgnoreClusterName;
|
return clientIgnoreClusterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClientIgnoreClusterName(Boolean clientIgnoreClusterName) {
|
public void setClientIgnoreClusterName(Boolean clientIgnoreClusterName) {
|
||||||
this.clientIgnoreClusterName = clientIgnoreClusterName;
|
this.clientIgnoreClusterName = clientIgnoreClusterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperties(Properties properties) {
|
public void setProperties(Properties properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-41
@@ -1,41 +1,41 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.config;
|
package org.springframework.data.elasticsearch.config;
|
||||||
|
|
||||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||||
import org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension;
|
import org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension;
|
||||||
import org.springframework.data.repository.config.RepositoryBeanDefinitionParser;
|
import org.springframework.data.repository.config.RepositoryBeanDefinitionParser;
|
||||||
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchNamespaceHandler
|
* ElasticsearchNamespaceHandler
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ElasticsearchNamespaceHandler extends NamespaceHandlerSupport {
|
public class ElasticsearchNamespaceHandler extends NamespaceHandlerSupport {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
RepositoryConfigurationExtension extension = new ElasticsearchRepositoryConfigExtension();
|
RepositoryConfigurationExtension extension = new ElasticsearchRepositoryConfigExtension();
|
||||||
RepositoryBeanDefinitionParser parser = new RepositoryBeanDefinitionParser(extension);
|
RepositoryBeanDefinitionParser parser = new RepositoryBeanDefinitionParser(extension);
|
||||||
|
|
||||||
registerBeanDefinitionParser("repositories", parser);
|
registerBeanDefinitionParser("repositories", parser);
|
||||||
registerBeanDefinitionParser("node-client", new NodeClientBeanDefinitionParser());
|
registerBeanDefinitionParser("node-client", new NodeClientBeanDefinitionParser());
|
||||||
registerBeanDefinitionParser("transport-client", new TransportClientBeanDefinitionParser());
|
registerBeanDefinitionParser("transport-client", new TransportClientBeanDefinitionParser());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+57
-57
@@ -1,57 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015 the original author or authors.
|
* Copyright 2015-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.data.elasticsearch.config;
|
package org.springframework.data.elasticsearch.config;
|
||||||
|
|
||||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
||||||
import org.springframework.beans.factory.xml.ParserContext;
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
import org.springframework.data.elasticsearch.client.NodeClientFactoryBean;
|
import org.springframework.data.elasticsearch.client.NodeClientFactoryBean;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NodeClientBeanDefinitionParser
|
* NodeClientBeanDefinitionParser
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class NodeClientBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
public class NodeClientBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(NodeClientFactoryBean.class);
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(NodeClientFactoryBean.class);
|
||||||
setLocalSettings(element, builder);
|
setLocalSettings(element, builder);
|
||||||
return getSourcedBeanDefinition(builder, element, parserContext);
|
return getSourcedBeanDefinition(builder, element, parserContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLocalSettings(Element element, BeanDefinitionBuilder builder) {
|
private void setLocalSettings(Element element, BeanDefinitionBuilder builder) {
|
||||||
builder.addPropertyValue("local", Boolean.valueOf(element.getAttribute("local")));
|
builder.addPropertyValue("local", Boolean.valueOf(element.getAttribute("local")));
|
||||||
builder.addPropertyValue("clusterName", element.getAttribute("cluster-name"));
|
builder.addPropertyValue("clusterName", element.getAttribute("cluster-name"));
|
||||||
builder.addPropertyValue("enableHttp", Boolean.valueOf(element.getAttribute("http-enabled")));
|
builder.addPropertyValue("enableHttp", Boolean.valueOf(element.getAttribute("http-enabled")));
|
||||||
builder.addPropertyValue("pathData", element.getAttribute("path-data"));
|
builder.addPropertyValue("pathData", element.getAttribute("path-data"));
|
||||||
builder.addPropertyValue("pathHome", element.getAttribute("path-home"));
|
builder.addPropertyValue("pathHome", element.getAttribute("path-home"));
|
||||||
builder.addPropertyValue("pathConfiguration", element.getAttribute("path-configuration"));
|
builder.addPropertyValue("pathConfiguration", element.getAttribute("path-configuration"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Element source,
|
private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Element source,
|
||||||
ParserContext context) {
|
ParserContext context) {
|
||||||
AbstractBeanDefinition definition = builder.getBeanDefinition();
|
AbstractBeanDefinition definition = builder.getBeanDefinition();
|
||||||
definition.setSource(context.extractSource(source));
|
definition.setSource(context.extractSource(source));
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+56
-56
@@ -1,56 +1,56 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.config;
|
package org.springframework.data.elasticsearch.config;
|
||||||
|
|
||||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
||||||
import org.springframework.beans.factory.xml.ParserContext;
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
import org.springframework.data.elasticsearch.client.TransportClientFactoryBean;
|
import org.springframework.data.elasticsearch.client.TransportClientFactoryBean;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TransportClientBeanDefinitionParser
|
* TransportClientBeanDefinitionParser
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TransportClientBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
public class TransportClientBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TransportClientFactoryBean.class);
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TransportClientFactoryBean.class);
|
||||||
setConfigurations(element, builder);
|
setConfigurations(element, builder);
|
||||||
return getSourcedBeanDefinition(builder, element, parserContext);
|
return getSourcedBeanDefinition(builder, element, parserContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConfigurations(Element element, BeanDefinitionBuilder builder) {
|
private void setConfigurations(Element element, BeanDefinitionBuilder builder) {
|
||||||
builder.addPropertyValue("clusterNodes", element.getAttribute("cluster-nodes"));
|
builder.addPropertyValue("clusterNodes", element.getAttribute("cluster-nodes"));
|
||||||
builder.addPropertyValue("clusterName", element.getAttribute("cluster-name"));
|
builder.addPropertyValue("clusterName", element.getAttribute("cluster-name"));
|
||||||
builder.addPropertyValue("clientTransportSniff", Boolean.valueOf(element.getAttribute("client-transport-sniff")));
|
builder.addPropertyValue("clientTransportSniff", Boolean.valueOf(element.getAttribute("client-transport-sniff")));
|
||||||
builder.addPropertyValue("clientIgnoreClusterName", Boolean.valueOf(element.getAttribute("client-transport-ignore-cluster-name")));
|
builder.addPropertyValue("clientIgnoreClusterName", Boolean.valueOf(element.getAttribute("client-transport-ignore-cluster-name")));
|
||||||
builder.addPropertyValue("clientPingTimeout", element.getAttribute("client-transport-ping-timeout"));
|
builder.addPropertyValue("clientPingTimeout", element.getAttribute("client-transport-ping-timeout"));
|
||||||
builder.addPropertyValue("clientNodesSamplerInterval", element.getAttribute("client-transport-nodes-sampler-interval"));
|
builder.addPropertyValue("clientNodesSamplerInterval", element.getAttribute("client-transport-nodes-sampler-interval"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Element source,
|
private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Element source,
|
||||||
ParserContext context) {
|
ParserContext context) {
|
||||||
AbstractBeanDefinition definition = builder.getBeanDefinition();
|
AbstractBeanDefinition definition = builder.getBeanDefinition();
|
||||||
definition.setSource(context.extractSource(source));
|
definition.setSource(context.extractSource(source));
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+210
-210
@@ -1,210 +1,210 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||||
import static org.springframework.data.elasticsearch.core.query.Criteria.*;
|
import static org.springframework.data.elasticsearch.core.query.Criteria.*;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import org.apache.lucene.queryparser.flexible.core.util.StringUtils;
|
import org.apache.lucene.queryparser.flexible.core.util.StringUtils;
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
import org.elasticsearch.index.query.BoostableQueryBuilder;
|
import org.elasticsearch.index.query.BoostableQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryStringQueryBuilder;
|
import org.elasticsearch.index.query.QueryStringQueryBuilder;
|
||||||
import org.springframework.data.elasticsearch.core.query.Criteria;
|
import org.springframework.data.elasticsearch.core.query.Criteria;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CriteriaQueryProcessor
|
* CriteriaQueryProcessor
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Franck Marchand
|
* @author Franck Marchand
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
class CriteriaQueryProcessor {
|
class CriteriaQueryProcessor {
|
||||||
|
|
||||||
|
|
||||||
QueryBuilder createQueryFromCriteria(Criteria criteria) {
|
QueryBuilder createQueryFromCriteria(Criteria criteria) {
|
||||||
if (criteria == null)
|
if (criteria == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<QueryBuilder> shouldQueryBuilderList = new LinkedList<QueryBuilder>();
|
List<QueryBuilder> shouldQueryBuilderList = new LinkedList<QueryBuilder>();
|
||||||
List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<QueryBuilder>();
|
List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<QueryBuilder>();
|
||||||
List<QueryBuilder> mustQueryBuilderList = new LinkedList<QueryBuilder>();
|
List<QueryBuilder> mustQueryBuilderList = new LinkedList<QueryBuilder>();
|
||||||
|
|
||||||
ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();
|
ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();
|
||||||
|
|
||||||
QueryBuilder firstQuery = null;
|
QueryBuilder firstQuery = null;
|
||||||
boolean negateFirstQuery = false;
|
boolean negateFirstQuery = false;
|
||||||
|
|
||||||
while (chainIterator.hasNext()) {
|
while (chainIterator.hasNext()) {
|
||||||
Criteria chainedCriteria = chainIterator.next();
|
Criteria chainedCriteria = chainIterator.next();
|
||||||
QueryBuilder queryFragmentForCriteria = createQueryFragmentForCriteria(chainedCriteria);
|
QueryBuilder queryFragmentForCriteria = createQueryFragmentForCriteria(chainedCriteria);
|
||||||
if (queryFragmentForCriteria != null) {
|
if (queryFragmentForCriteria != null) {
|
||||||
if (firstQuery == null) {
|
if (firstQuery == null) {
|
||||||
firstQuery = queryFragmentForCriteria;
|
firstQuery = queryFragmentForCriteria;
|
||||||
negateFirstQuery = chainedCriteria.isNegating();
|
negateFirstQuery = chainedCriteria.isNegating();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (chainedCriteria.isOr()) {
|
if (chainedCriteria.isOr()) {
|
||||||
shouldQueryBuilderList.add(queryFragmentForCriteria);
|
shouldQueryBuilderList.add(queryFragmentForCriteria);
|
||||||
} else if (chainedCriteria.isNegating()) {
|
} else if (chainedCriteria.isNegating()) {
|
||||||
mustNotQueryBuilderList.add(queryFragmentForCriteria);
|
mustNotQueryBuilderList.add(queryFragmentForCriteria);
|
||||||
} else {
|
} else {
|
||||||
mustQueryBuilderList.add(queryFragmentForCriteria);
|
mustQueryBuilderList.add(queryFragmentForCriteria);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstQuery != null) {
|
if (firstQuery != null) {
|
||||||
if (!shouldQueryBuilderList.isEmpty() && mustNotQueryBuilderList.isEmpty() && mustQueryBuilderList.isEmpty()) {
|
if (!shouldQueryBuilderList.isEmpty() && mustNotQueryBuilderList.isEmpty() && mustQueryBuilderList.isEmpty()) {
|
||||||
shouldQueryBuilderList.add(0, firstQuery);
|
shouldQueryBuilderList.add(0, firstQuery);
|
||||||
} else {
|
} else {
|
||||||
if (negateFirstQuery) {
|
if (negateFirstQuery) {
|
||||||
mustNotQueryBuilderList.add(0, firstQuery);
|
mustNotQueryBuilderList.add(0, firstQuery);
|
||||||
} else {
|
} else {
|
||||||
mustQueryBuilderList.add(0, firstQuery);
|
mustQueryBuilderList.add(0, firstQuery);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BoolQueryBuilder query = null;
|
BoolQueryBuilder query = null;
|
||||||
|
|
||||||
if (!shouldQueryBuilderList.isEmpty() || !mustNotQueryBuilderList.isEmpty() || !mustQueryBuilderList.isEmpty()) {
|
if (!shouldQueryBuilderList.isEmpty() || !mustNotQueryBuilderList.isEmpty() || !mustQueryBuilderList.isEmpty()) {
|
||||||
|
|
||||||
query = boolQuery();
|
query = boolQuery();
|
||||||
|
|
||||||
for (QueryBuilder qb : shouldQueryBuilderList) {
|
for (QueryBuilder qb : shouldQueryBuilderList) {
|
||||||
query.should(qb);
|
query.should(qb);
|
||||||
}
|
}
|
||||||
for (QueryBuilder qb : mustNotQueryBuilderList) {
|
for (QueryBuilder qb : mustNotQueryBuilderList) {
|
||||||
query.mustNot(qb);
|
query.mustNot(qb);
|
||||||
}
|
}
|
||||||
for (QueryBuilder qb : mustQueryBuilderList) {
|
for (QueryBuilder qb : mustQueryBuilderList) {
|
||||||
query.must(qb);
|
query.must(qb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private QueryBuilder createQueryFragmentForCriteria(Criteria chainedCriteria) {
|
private QueryBuilder createQueryFragmentForCriteria(Criteria chainedCriteria) {
|
||||||
if (chainedCriteria.getQueryCriteriaEntries().isEmpty())
|
if (chainedCriteria.getQueryCriteriaEntries().isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Iterator<Criteria.CriteriaEntry> it = chainedCriteria.getQueryCriteriaEntries().iterator();
|
Iterator<Criteria.CriteriaEntry> it = chainedCriteria.getQueryCriteriaEntries().iterator();
|
||||||
boolean singeEntryCriteria = (chainedCriteria.getQueryCriteriaEntries().size() == 1);
|
boolean singeEntryCriteria = (chainedCriteria.getQueryCriteriaEntries().size() == 1);
|
||||||
|
|
||||||
String fieldName = chainedCriteria.getField().getName();
|
String fieldName = chainedCriteria.getField().getName();
|
||||||
Assert.notNull(fieldName, "Unknown field");
|
Assert.notNull(fieldName, "Unknown field");
|
||||||
QueryBuilder query = null;
|
QueryBuilder query = null;
|
||||||
|
|
||||||
if (singeEntryCriteria) {
|
if (singeEntryCriteria) {
|
||||||
Criteria.CriteriaEntry entry = it.next();
|
Criteria.CriteriaEntry entry = it.next();
|
||||||
query = processCriteriaEntry(entry, fieldName);
|
query = processCriteriaEntry(entry, fieldName);
|
||||||
} else {
|
} else {
|
||||||
query = boolQuery();
|
query = boolQuery();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Criteria.CriteriaEntry entry = it.next();
|
Criteria.CriteriaEntry entry = it.next();
|
||||||
((BoolQueryBuilder) query).must(processCriteriaEntry(entry, fieldName));
|
((BoolQueryBuilder) query).must(processCriteriaEntry(entry, fieldName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addBoost(query, chainedCriteria.getBoost());
|
addBoost(query, chainedCriteria.getBoost());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private QueryBuilder processCriteriaEntry(Criteria.CriteriaEntry entry,/* OperationKey key, Object value,*/ String fieldName) {
|
private QueryBuilder processCriteriaEntry(Criteria.CriteriaEntry entry,/* OperationKey key, Object value,*/ String fieldName) {
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
OperationKey key = entry.getKey();
|
OperationKey key = entry.getKey();
|
||||||
QueryBuilder query = null;
|
QueryBuilder query = null;
|
||||||
|
|
||||||
String searchText = StringUtils.toString(value);
|
String searchText = StringUtils.toString(value);
|
||||||
|
|
||||||
Iterable<Object> collection = null;
|
Iterable<Object> collection = null;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case EQUALS:
|
case EQUALS:
|
||||||
query = queryStringQuery(searchText).field(fieldName).defaultOperator(QueryStringQueryBuilder.Operator.AND);
|
query = queryStringQuery(searchText).field(fieldName).defaultOperator(QueryStringQueryBuilder.Operator.AND);
|
||||||
break;
|
break;
|
||||||
case CONTAINS:
|
case CONTAINS:
|
||||||
query = queryStringQuery("*" + searchText + "*").field(fieldName).analyzeWildcard(true);
|
query = queryStringQuery("*" + searchText + "*").field(fieldName).analyzeWildcard(true);
|
||||||
break;
|
break;
|
||||||
case STARTS_WITH:
|
case STARTS_WITH:
|
||||||
query = queryStringQuery(searchText + "*").field(fieldName).analyzeWildcard(true);
|
query = queryStringQuery(searchText + "*").field(fieldName).analyzeWildcard(true);
|
||||||
break;
|
break;
|
||||||
case ENDS_WITH:
|
case ENDS_WITH:
|
||||||
query = queryStringQuery("*" + searchText).field(fieldName).analyzeWildcard(true);
|
query = queryStringQuery("*" + searchText).field(fieldName).analyzeWildcard(true);
|
||||||
break;
|
break;
|
||||||
case EXPRESSION:
|
case EXPRESSION:
|
||||||
query = queryStringQuery(searchText).field(fieldName);
|
query = queryStringQuery(searchText).field(fieldName);
|
||||||
break;
|
break;
|
||||||
case LESS_EQUAL:
|
case LESS_EQUAL:
|
||||||
query = rangeQuery(fieldName).lte(value);
|
query = rangeQuery(fieldName).lte(value);
|
||||||
break;
|
break;
|
||||||
case GREATER_EQUAL:
|
case GREATER_EQUAL:
|
||||||
query = rangeQuery(fieldName).gte(value);
|
query = rangeQuery(fieldName).gte(value);
|
||||||
break;
|
break;
|
||||||
case BETWEEN:
|
case BETWEEN:
|
||||||
Object[] ranges = (Object[]) value;
|
Object[] ranges = (Object[]) value;
|
||||||
query = rangeQuery(fieldName).from(ranges[0]).to(ranges[1]);
|
query = rangeQuery(fieldName).from(ranges[0]).to(ranges[1]);
|
||||||
break;
|
break;
|
||||||
case LESS:
|
case LESS:
|
||||||
query = rangeQuery(fieldName).lt(value);
|
query = rangeQuery(fieldName).lt(value);
|
||||||
break;
|
break;
|
||||||
case GREATER:
|
case GREATER:
|
||||||
query = rangeQuery(fieldName).gt(value);
|
query = rangeQuery(fieldName).gt(value);
|
||||||
break;
|
break;
|
||||||
case FUZZY:
|
case FUZZY:
|
||||||
query = fuzzyQuery(fieldName, searchText);
|
query = fuzzyQuery(fieldName, searchText);
|
||||||
break;
|
break;
|
||||||
case IN:
|
case IN:
|
||||||
query = boolQuery();
|
query = boolQuery();
|
||||||
collection = (Iterable<Object>) value;
|
collection = (Iterable<Object>) value;
|
||||||
for (Object item : collection) {
|
for (Object item : collection) {
|
||||||
((BoolQueryBuilder) query).should(queryStringQuery(item.toString()).field(fieldName));
|
((BoolQueryBuilder) query).should(queryStringQuery(item.toString()).field(fieldName));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NOT_IN:
|
case NOT_IN:
|
||||||
query = boolQuery();
|
query = boolQuery();
|
||||||
collection = (Iterable<Object>) value;
|
collection = (Iterable<Object>) value;
|
||||||
for (Object item : collection) {
|
for (Object item : collection) {
|
||||||
((BoolQueryBuilder) query).mustNot(queryStringQuery(item.toString()).field(fieldName));
|
((BoolQueryBuilder) query).mustNot(queryStringQuery(item.toString()).field(fieldName));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBoost(QueryBuilder query, float boost) {
|
private void addBoost(QueryBuilder query, float boost) {
|
||||||
if (Float.isNaN(boost)) {
|
if (Float.isNaN(boost)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (query instanceof BoostableQueryBuilder) {
|
if (query instanceof BoostableQueryBuilder) {
|
||||||
((BoostableQueryBuilder) query).boost(boost);
|
((BoostableQueryBuilder) query).boost(boost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2016 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+603
-603
File diff suppressed because it is too large
Load Diff
+1204
-1204
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,361 +1,361 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2016 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
import static org.apache.commons.lang.StringUtils.*;
|
import static org.apache.commons.lang.StringUtils.*;
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
||||||
import static org.springframework.util.StringUtils.*;
|
import static org.springframework.util.StringUtils.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.springframework.core.GenericCollectionTypeResolver;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.data.annotation.Transient;
|
||||||
import org.springframework.data.annotation.Transient;
|
import org.springframework.data.elasticsearch.annotations.*;
|
||||||
import org.springframework.data.elasticsearch.annotations.*;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.core.completion.Completion;
|
||||||
import org.springframework.data.elasticsearch.core.completion.Completion;
|
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||||
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
import org.springframework.data.util.ClassTypeInformation;
|
||||||
import org.springframework.data.util.ClassTypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.data.util.TypeInformation;
|
|
||||||
|
/**
|
||||||
/**
|
* @author Rizwan Idrees
|
||||||
* @author Rizwan Idrees
|
* @author Mohsin Husen
|
||||||
* @author Mohsin Husen
|
* @author Artur Konczak
|
||||||
* @author Artur Konczak
|
* @author Kevin Leturc
|
||||||
* @author Kevin Leturc
|
* @author Alexander Volz
|
||||||
* @author Alexander Volz
|
* @author Dennis Maaß
|
||||||
* @author Dennis Maaß
|
* @author Pavel Luhin
|
||||||
* @author Pavel Luhin
|
* @author Oliver Gierke
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class MappingBuilder {
|
class MappingBuilder {
|
||||||
|
|
||||||
public static final String FIELD_STORE = "store";
|
public static final String FIELD_STORE = "store";
|
||||||
public static final String FIELD_TYPE = "type";
|
public static final String FIELD_TYPE = "type";
|
||||||
public static final String FIELD_INDEX = "index";
|
public static final String FIELD_INDEX = "index";
|
||||||
public static final String FIELD_FORMAT = "format";
|
public static final String FIELD_FORMAT = "format";
|
||||||
public static final String FIELD_SEARCH_ANALYZER = "search_analyzer";
|
public static final String FIELD_SEARCH_ANALYZER = "search_analyzer";
|
||||||
public static final String FIELD_INDEX_ANALYZER = "analyzer";
|
public static final String FIELD_INDEX_ANALYZER = "analyzer";
|
||||||
public static final String FIELD_PROPERTIES = "properties";
|
public static final String FIELD_PROPERTIES = "properties";
|
||||||
public static final String FIELD_PARENT = "_parent";
|
public static final String FIELD_PARENT = "_parent";
|
||||||
|
|
||||||
public static final String COMPLETION_PAYLOADS = "payloads";
|
public static final String COMPLETION_PAYLOADS = "payloads";
|
||||||
public static final String COMPLETION_PRESERVE_SEPARATORS = "preserve_separators";
|
public static final String COMPLETION_PRESERVE_SEPARATORS = "preserve_separators";
|
||||||
public static final String COMPLETION_PRESERVE_POSITION_INCREMENTS = "preserve_position_increments";
|
public static final String COMPLETION_PRESERVE_POSITION_INCREMENTS = "preserve_position_increments";
|
||||||
public static final String COMPLETION_MAX_INPUT_LENGTH = "max_input_length";
|
public static final String COMPLETION_MAX_INPUT_LENGTH = "max_input_length";
|
||||||
|
|
||||||
public static final String INDEX_VALUE_NOT_ANALYZED = "not_analyzed";
|
public static final String INDEX_VALUE_NOT_ANALYZED = "not_analyzed";
|
||||||
public static final String TYPE_VALUE_STRING = "string";
|
public static final String TYPE_VALUE_STRING = "string";
|
||||||
public static final String TYPE_VALUE_GEO_POINT = "geo_point";
|
public static final String TYPE_VALUE_GEO_POINT = "geo_point";
|
||||||
public static final String TYPE_VALUE_COMPLETION = "completion";
|
public static final String TYPE_VALUE_COMPLETION = "completion";
|
||||||
public static final String TYPE_VALUE_GEO_HASH_PREFIX = "geohash_prefix";
|
public static final String TYPE_VALUE_GEO_HASH_PREFIX = "geohash_prefix";
|
||||||
public static final String TYPE_VALUE_GEO_HASH_PRECISION = "geohash_precision";
|
public static final String TYPE_VALUE_GEO_HASH_PRECISION = "geohash_precision";
|
||||||
|
|
||||||
private static SimpleTypeHolder SIMPLE_TYPE_HOLDER = new SimpleTypeHolder();
|
private static SimpleTypeHolder SIMPLE_TYPE_HOLDER = new SimpleTypeHolder();
|
||||||
|
|
||||||
static XContentBuilder buildMapping(Class clazz, String indexType, String idFieldName, String parentType) throws IOException {
|
static XContentBuilder buildMapping(Class clazz, String indexType, String idFieldName, String parentType) throws IOException {
|
||||||
|
|
||||||
XContentBuilder mapping = jsonBuilder().startObject().startObject(indexType);
|
XContentBuilder mapping = jsonBuilder().startObject().startObject(indexType);
|
||||||
// Parent
|
// Parent
|
||||||
if (hasText(parentType)) {
|
if (hasText(parentType)) {
|
||||||
mapping.startObject(FIELD_PARENT).field(FIELD_TYPE, parentType).endObject();
|
mapping.startObject(FIELD_PARENT).field(FIELD_TYPE, parentType).endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
XContentBuilder xContentBuilder = mapping.startObject(FIELD_PROPERTIES);
|
XContentBuilder xContentBuilder = mapping.startObject(FIELD_PROPERTIES);
|
||||||
|
|
||||||
mapEntity(xContentBuilder, clazz, true, idFieldName, EMPTY, false, FieldType.Auto, null);
|
mapEntity(xContentBuilder, clazz, true, idFieldName, EMPTY, false, FieldType.Auto, null);
|
||||||
|
|
||||||
return xContentBuilder.endObject().endObject().endObject();
|
return xContentBuilder.endObject().endObject().endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void mapEntity(XContentBuilder xContentBuilder, Class clazz, boolean isRootObject, String idFieldName,
|
private static void mapEntity(XContentBuilder xContentBuilder, Class clazz, boolean isRootObject, String idFieldName,
|
||||||
String nestedObjectFieldName, boolean nestedOrObjectField, FieldType fieldType, Field fieldAnnotation) throws IOException {
|
String nestedObjectFieldName, boolean nestedOrObjectField, FieldType fieldType, Field fieldAnnotation) throws IOException {
|
||||||
|
|
||||||
java.lang.reflect.Field[] fields = retrieveFields(clazz);
|
java.lang.reflect.Field[] fields = retrieveFields(clazz);
|
||||||
|
|
||||||
if (!isRootObject && (isAnyPropertyAnnotatedAsField(fields) || nestedOrObjectField)) {
|
if (!isRootObject && (isAnyPropertyAnnotatedAsField(fields) || nestedOrObjectField)) {
|
||||||
String type = FieldType.Object.toString().toLowerCase();
|
String type = FieldType.Object.toString().toLowerCase();
|
||||||
if (nestedOrObjectField) {
|
if (nestedOrObjectField) {
|
||||||
type = fieldType.toString().toLowerCase();
|
type = fieldType.toString().toLowerCase();
|
||||||
}
|
}
|
||||||
XContentBuilder t = xContentBuilder.startObject(nestedObjectFieldName).field(FIELD_TYPE, type);
|
XContentBuilder t = xContentBuilder.startObject(nestedObjectFieldName).field(FIELD_TYPE, type);
|
||||||
|
|
||||||
if (nestedOrObjectField && FieldType.Nested == fieldType && fieldAnnotation.includeInParent()) {
|
if (nestedOrObjectField && FieldType.Nested == fieldType && fieldAnnotation.includeInParent()) {
|
||||||
t.field("include_in_parent", fieldAnnotation.includeInParent());
|
t.field("include_in_parent", fieldAnnotation.includeInParent());
|
||||||
}
|
}
|
||||||
t.startObject(FIELD_PROPERTIES);
|
t.startObject(FIELD_PROPERTIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (java.lang.reflect.Field field : fields) {
|
for (java.lang.reflect.Field field : fields) {
|
||||||
|
|
||||||
if (field.isAnnotationPresent(Transient.class) || isInIgnoreFields(field, fieldAnnotation)) {
|
if (field.isAnnotationPresent(Transient.class) || isInIgnoreFields(field, fieldAnnotation)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.isAnnotationPresent(Mapping.class)) {
|
if (field.isAnnotationPresent(Mapping.class)) {
|
||||||
String mappingPath = field.getAnnotation(Mapping.class).mappingPath();
|
String mappingPath = field.getAnnotation(Mapping.class).mappingPath();
|
||||||
if (isNotBlank(mappingPath)) {
|
if (isNotBlank(mappingPath)) {
|
||||||
ClassPathResource mappings = new ClassPathResource(mappingPath);
|
ClassPathResource mappings = new ClassPathResource(mappingPath);
|
||||||
if (mappings.exists()) {
|
if (mappings.exists()) {
|
||||||
xContentBuilder.rawField(field.getName(), mappings.getInputStream());
|
xContentBuilder.rawField(field.getName(), mappings.getInputStream());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isGeoPointField = isGeoPointField(field);
|
boolean isGeoPointField = isGeoPointField(field);
|
||||||
boolean isCompletionField = isCompletionField(field);
|
boolean isCompletionField = isCompletionField(field);
|
||||||
|
|
||||||
Field singleField = field.getAnnotation(Field.class);
|
Field singleField = field.getAnnotation(Field.class);
|
||||||
if (!isGeoPointField && !isCompletionField && isEntity(field) && isAnnotated(field)) {
|
if (!isGeoPointField && !isCompletionField && isEntity(field) && isAnnotated(field)) {
|
||||||
if (singleField == null) {
|
if (singleField == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean nestedOrObject = isNestedOrObjectField(field);
|
boolean nestedOrObject = isNestedOrObjectField(field);
|
||||||
mapEntity(xContentBuilder, getFieldType(field), false, EMPTY, field.getName(), nestedOrObject, singleField.type(), field.getAnnotation(Field.class));
|
mapEntity(xContentBuilder, getFieldType(field), false, EMPTY, field.getName(), nestedOrObject, singleField.type(), field.getAnnotation(Field.class));
|
||||||
if (nestedOrObject) {
|
if (nestedOrObject) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiField multiField = field.getAnnotation(MultiField.class);
|
MultiField multiField = field.getAnnotation(MultiField.class);
|
||||||
|
|
||||||
if (isGeoPointField) {
|
if (isGeoPointField) {
|
||||||
applyGeoPointFieldMapping(xContentBuilder, field);
|
applyGeoPointFieldMapping(xContentBuilder, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCompletionField) {
|
if (isCompletionField) {
|
||||||
CompletionField completionField = field.getAnnotation(CompletionField.class);
|
CompletionField completionField = field.getAnnotation(CompletionField.class);
|
||||||
applyCompletionFieldMapping(xContentBuilder, field, completionField);
|
applyCompletionFieldMapping(xContentBuilder, field, completionField);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRootObject && singleField != null && isIdField(field, idFieldName)) {
|
if (isRootObject && singleField != null && isIdField(field, idFieldName)) {
|
||||||
applyDefaultIdFieldMapping(xContentBuilder, field);
|
applyDefaultIdFieldMapping(xContentBuilder, field);
|
||||||
} else if (multiField != null) {
|
} else if (multiField != null) {
|
||||||
addMultiFieldMapping(xContentBuilder, field, multiField, isNestedOrObjectField(field));
|
addMultiFieldMapping(xContentBuilder, field, multiField, isNestedOrObjectField(field));
|
||||||
} else if (singleField != null) {
|
} else if (singleField != null) {
|
||||||
addSingleFieldMapping(xContentBuilder, field, singleField, isNestedOrObjectField(field));
|
addSingleFieldMapping(xContentBuilder, field, singleField, isNestedOrObjectField(field));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isRootObject && isAnyPropertyAnnotatedAsField(fields) || nestedOrObjectField) {
|
if (!isRootObject && isAnyPropertyAnnotatedAsField(fields) || nestedOrObjectField) {
|
||||||
xContentBuilder.endObject().endObject();
|
xContentBuilder.endObject().endObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static java.lang.reflect.Field[] retrieveFields(Class clazz) {
|
private static java.lang.reflect.Field[] retrieveFields(Class clazz) {
|
||||||
// Create list of fields.
|
// Create list of fields.
|
||||||
List<java.lang.reflect.Field> fields = new ArrayList<java.lang.reflect.Field>();
|
List<java.lang.reflect.Field> fields = new ArrayList<java.lang.reflect.Field>();
|
||||||
|
|
||||||
// Keep backing up the inheritance hierarchy.
|
// Keep backing up the inheritance hierarchy.
|
||||||
Class targetClass = clazz;
|
Class targetClass = clazz;
|
||||||
do {
|
do {
|
||||||
fields.addAll(Arrays.asList(targetClass.getDeclaredFields()));
|
fields.addAll(Arrays.asList(targetClass.getDeclaredFields()));
|
||||||
targetClass = targetClass.getSuperclass();
|
targetClass = targetClass.getSuperclass();
|
||||||
}
|
}
|
||||||
while (targetClass != null && targetClass != Object.class);
|
while (targetClass != null && targetClass != Object.class);
|
||||||
|
|
||||||
return fields.toArray(new java.lang.reflect.Field[fields.size()]);
|
return fields.toArray(new java.lang.reflect.Field[fields.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAnnotated(java.lang.reflect.Field field) {
|
private static boolean isAnnotated(java.lang.reflect.Field field) {
|
||||||
return field.getAnnotation(Field.class) != null ||
|
return field.getAnnotation(Field.class) != null ||
|
||||||
field.getAnnotation(MultiField.class) != null ||
|
field.getAnnotation(MultiField.class) != null ||
|
||||||
field.getAnnotation(GeoPointField.class) != null ||
|
field.getAnnotation(GeoPointField.class) != null ||
|
||||||
field.getAnnotation(CompletionField.class) != null;
|
field.getAnnotation(CompletionField.class) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyGeoPointFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field) throws IOException {
|
private static void applyGeoPointFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field) throws IOException {
|
||||||
xContentBuilder.startObject(field.getName());
|
xContentBuilder.startObject(field.getName());
|
||||||
xContentBuilder.field(FIELD_TYPE, TYPE_VALUE_GEO_POINT);
|
xContentBuilder.field(FIELD_TYPE, TYPE_VALUE_GEO_POINT);
|
||||||
|
|
||||||
GeoPointField annotation = field.getAnnotation(GeoPointField.class);
|
GeoPointField annotation = field.getAnnotation(GeoPointField.class);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
if (annotation.geoHashPrefix()) {
|
if (annotation.geoHashPrefix()) {
|
||||||
xContentBuilder.field(TYPE_VALUE_GEO_HASH_PREFIX, true);
|
xContentBuilder.field(TYPE_VALUE_GEO_HASH_PREFIX, true);
|
||||||
if (StringUtils.isNotEmpty(annotation.geoHashPrecision())) {
|
if (StringUtils.isNotEmpty(annotation.geoHashPrecision())) {
|
||||||
if (NumberUtils.isNumber(annotation.geoHashPrecision())) {
|
if (NumberUtils.isNumber(annotation.geoHashPrecision())) {
|
||||||
xContentBuilder.field(TYPE_VALUE_GEO_HASH_PRECISION, Integer.parseInt(annotation.geoHashPrecision()));
|
xContentBuilder.field(TYPE_VALUE_GEO_HASH_PRECISION, Integer.parseInt(annotation.geoHashPrecision()));
|
||||||
} else {
|
} else {
|
||||||
xContentBuilder.field(TYPE_VALUE_GEO_HASH_PRECISION, annotation.geoHashPrecision());
|
xContentBuilder.field(TYPE_VALUE_GEO_HASH_PRECISION, annotation.geoHashPrecision());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xContentBuilder.endObject();
|
xContentBuilder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyCompletionFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field, CompletionField annotation) throws IOException {
|
private static void applyCompletionFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field, CompletionField annotation) throws IOException {
|
||||||
xContentBuilder.startObject(field.getName());
|
xContentBuilder.startObject(field.getName());
|
||||||
xContentBuilder.field(FIELD_TYPE, TYPE_VALUE_COMPLETION);
|
xContentBuilder.field(FIELD_TYPE, TYPE_VALUE_COMPLETION);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
xContentBuilder.field(COMPLETION_MAX_INPUT_LENGTH, annotation.maxInputLength());
|
xContentBuilder.field(COMPLETION_MAX_INPUT_LENGTH, annotation.maxInputLength());
|
||||||
xContentBuilder.field(COMPLETION_PAYLOADS, annotation.payloads());
|
xContentBuilder.field(COMPLETION_PAYLOADS, annotation.payloads());
|
||||||
xContentBuilder.field(COMPLETION_PRESERVE_POSITION_INCREMENTS, annotation.preservePositionIncrements());
|
xContentBuilder.field(COMPLETION_PRESERVE_POSITION_INCREMENTS, annotation.preservePositionIncrements());
|
||||||
xContentBuilder.field(COMPLETION_PRESERVE_SEPARATORS, annotation.preserveSeparators());
|
xContentBuilder.field(COMPLETION_PRESERVE_SEPARATORS, annotation.preserveSeparators());
|
||||||
if (isNotBlank(annotation.searchAnalyzer())) {
|
if (isNotBlank(annotation.searchAnalyzer())) {
|
||||||
xContentBuilder.field(FIELD_SEARCH_ANALYZER, annotation.searchAnalyzer());
|
xContentBuilder.field(FIELD_SEARCH_ANALYZER, annotation.searchAnalyzer());
|
||||||
}
|
}
|
||||||
if (isNotBlank(annotation.analyzer())) {
|
if (isNotBlank(annotation.analyzer())) {
|
||||||
xContentBuilder.field(FIELD_INDEX_ANALYZER, annotation.analyzer());
|
xContentBuilder.field(FIELD_INDEX_ANALYZER, annotation.analyzer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xContentBuilder.endObject();
|
xContentBuilder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyDefaultIdFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field)
|
private static void applyDefaultIdFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
xContentBuilder.startObject(field.getName())
|
xContentBuilder.startObject(field.getName())
|
||||||
.field(FIELD_TYPE, TYPE_VALUE_STRING)
|
.field(FIELD_TYPE, TYPE_VALUE_STRING)
|
||||||
.field(FIELD_INDEX, INDEX_VALUE_NOT_ANALYZED);
|
.field(FIELD_INDEX, INDEX_VALUE_NOT_ANALYZED);
|
||||||
xContentBuilder.endObject();
|
xContentBuilder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply mapping for a single @Field annotation
|
* Apply mapping for a single @Field annotation
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private static void addSingleFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field,
|
private static void addSingleFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field,
|
||||||
Field fieldAnnotation, boolean nestedOrObjectField) throws IOException {
|
Field fieldAnnotation, boolean nestedOrObjectField) throws IOException {
|
||||||
xContentBuilder.startObject(field.getName());
|
xContentBuilder.startObject(field.getName());
|
||||||
if(!nestedOrObjectField) {
|
if(!nestedOrObjectField) {
|
||||||
xContentBuilder.field(FIELD_STORE, fieldAnnotation.store());
|
xContentBuilder.field(FIELD_STORE, fieldAnnotation.store());
|
||||||
}
|
}
|
||||||
if (FieldType.Auto != fieldAnnotation.type()) {
|
if (FieldType.Auto != fieldAnnotation.type()) {
|
||||||
xContentBuilder.field(FIELD_TYPE, fieldAnnotation.type().name().toLowerCase());
|
xContentBuilder.field(FIELD_TYPE, fieldAnnotation.type().name().toLowerCase());
|
||||||
if (FieldType.Date == fieldAnnotation.type() && DateFormat.none != fieldAnnotation.format()) {
|
if (FieldType.Date == fieldAnnotation.type() && DateFormat.none != fieldAnnotation.format()) {
|
||||||
xContentBuilder.field(FIELD_FORMAT, DateFormat.custom == fieldAnnotation.format()
|
xContentBuilder.field(FIELD_FORMAT, DateFormat.custom == fieldAnnotation.format()
|
||||||
? fieldAnnotation.pattern() : fieldAnnotation.format());
|
? fieldAnnotation.pattern() : fieldAnnotation.format());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (FieldIndex.not_analyzed == fieldAnnotation.index() || FieldIndex.no == fieldAnnotation.index()) {
|
if (FieldIndex.not_analyzed == fieldAnnotation.index() || FieldIndex.no == fieldAnnotation.index()) {
|
||||||
xContentBuilder.field(FIELD_INDEX, fieldAnnotation.index().name().toLowerCase());
|
xContentBuilder.field(FIELD_INDEX, fieldAnnotation.index().name().toLowerCase());
|
||||||
}
|
}
|
||||||
if (isNotBlank(fieldAnnotation.searchAnalyzer())) {
|
if (isNotBlank(fieldAnnotation.searchAnalyzer())) {
|
||||||
xContentBuilder.field(FIELD_SEARCH_ANALYZER, fieldAnnotation.searchAnalyzer());
|
xContentBuilder.field(FIELD_SEARCH_ANALYZER, fieldAnnotation.searchAnalyzer());
|
||||||
}
|
}
|
||||||
if (isNotBlank(fieldAnnotation.analyzer())) {
|
if (isNotBlank(fieldAnnotation.analyzer())) {
|
||||||
xContentBuilder.field(FIELD_INDEX_ANALYZER, fieldAnnotation.analyzer());
|
xContentBuilder.field(FIELD_INDEX_ANALYZER, fieldAnnotation.analyzer());
|
||||||
}
|
}
|
||||||
xContentBuilder.endObject();
|
xContentBuilder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply mapping for a single nested @Field annotation
|
* Apply mapping for a single nested @Field annotation
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private static void addNestedFieldMapping(XContentBuilder builder, java.lang.reflect.Field field,
|
private static void addNestedFieldMapping(XContentBuilder builder, java.lang.reflect.Field field,
|
||||||
InnerField annotation) throws IOException {
|
InnerField annotation) throws IOException {
|
||||||
builder.startObject(annotation.suffix());
|
builder.startObject(annotation.suffix());
|
||||||
//builder.field(FIELD_STORE, annotation.store());
|
//builder.field(FIELD_STORE, annotation.store());
|
||||||
if (FieldType.Auto != annotation.type()) {
|
if (FieldType.Auto != annotation.type()) {
|
||||||
builder.field(FIELD_TYPE, annotation.type().name().toLowerCase());
|
builder.field(FIELD_TYPE, annotation.type().name().toLowerCase());
|
||||||
}
|
}
|
||||||
if (FieldIndex.not_analyzed == annotation.index()) {
|
if (FieldIndex.not_analyzed == annotation.index()) {
|
||||||
builder.field(FIELD_INDEX, annotation.index().name().toLowerCase());
|
builder.field(FIELD_INDEX, annotation.index().name().toLowerCase());
|
||||||
}
|
}
|
||||||
if (isNotBlank(annotation.searchAnalyzer())) {
|
if (isNotBlank(annotation.searchAnalyzer())) {
|
||||||
builder.field(FIELD_SEARCH_ANALYZER, annotation.searchAnalyzer());
|
builder.field(FIELD_SEARCH_ANALYZER, annotation.searchAnalyzer());
|
||||||
}
|
}
|
||||||
if (isNotBlank(annotation.indexAnalyzer())) {
|
if (isNotBlank(annotation.indexAnalyzer())) {
|
||||||
builder.field(FIELD_INDEX_ANALYZER, annotation.indexAnalyzer());
|
builder.field(FIELD_INDEX_ANALYZER, annotation.indexAnalyzer());
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multi field mappings for string type fields, support for sorts and facets
|
* Multi field mappings for string type fields, support for sorts and facets
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private static void addMultiFieldMapping(XContentBuilder builder, java.lang.reflect.Field field,
|
private static void addMultiFieldMapping(XContentBuilder builder, java.lang.reflect.Field field,
|
||||||
MultiField annotation, boolean nestedOrObjectField) throws IOException {
|
MultiField annotation, boolean nestedOrObjectField) throws IOException {
|
||||||
builder.startObject(field.getName());
|
builder.startObject(field.getName());
|
||||||
builder.field(FIELD_TYPE, "multi_field");
|
builder.field(FIELD_TYPE, "multi_field");
|
||||||
builder.startObject("fields");
|
builder.startObject("fields");
|
||||||
//add standard field
|
//add standard field
|
||||||
addSingleFieldMapping(builder, field, annotation.mainField(),nestedOrObjectField);
|
addSingleFieldMapping(builder, field, annotation.mainField(),nestedOrObjectField);
|
||||||
for (InnerField innerField : annotation.otherFields()) {
|
for (InnerField innerField : annotation.otherFields()) {
|
||||||
addNestedFieldMapping(builder, field, innerField);
|
addNestedFieldMapping(builder, field, innerField);
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean isEntity(java.lang.reflect.Field field) {
|
protected static boolean isEntity(java.lang.reflect.Field field) {
|
||||||
TypeInformation typeInformation = ClassTypeInformation.from(field.getType());
|
|
||||||
Class<?> clazz = getFieldType(field);
|
TypeInformation<?> typeInformation = ClassTypeInformation.from(field.getType());
|
||||||
boolean isComplexType = !SIMPLE_TYPE_HOLDER.isSimpleType(clazz);
|
Class<?> clazz = getFieldType(field);
|
||||||
return isComplexType && !Map.class.isAssignableFrom(typeInformation.getType());
|
boolean isComplexType = !SIMPLE_TYPE_HOLDER.isSimpleType(clazz);
|
||||||
}
|
return isComplexType && !typeInformation.isMap();
|
||||||
|
}
|
||||||
protected static Class<?> getFieldType(java.lang.reflect.Field field) {
|
|
||||||
Class<?> clazz = field.getType();
|
protected static Class<?> getFieldType(java.lang.reflect.Field field) {
|
||||||
TypeInformation typeInformation = ClassTypeInformation.from(clazz);
|
|
||||||
if (typeInformation.isCollectionLike()) {
|
return ClassTypeInformation.from(field.getDeclaringClass()) //
|
||||||
clazz = GenericCollectionTypeResolver.getCollectionFieldType(field) != null ? GenericCollectionTypeResolver.getCollectionFieldType(field) : typeInformation.getComponentType().getType();
|
.getProperty(field.getName()) //
|
||||||
}
|
.getActualType() //
|
||||||
return clazz;
|
.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAnyPropertyAnnotatedAsField(java.lang.reflect.Field[] fields) {
|
private static boolean isAnyPropertyAnnotatedAsField(java.lang.reflect.Field[] fields) {
|
||||||
if (fields != null) {
|
if (fields != null) {
|
||||||
for (java.lang.reflect.Field field : fields) {
|
for (java.lang.reflect.Field field : fields) {
|
||||||
if (field.isAnnotationPresent(Field.class)) {
|
if (field.isAnnotationPresent(Field.class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isIdField(java.lang.reflect.Field field, String idFieldName) {
|
private static boolean isIdField(java.lang.reflect.Field field, String idFieldName) {
|
||||||
return idFieldName.equals(field.getName());
|
return idFieldName.equals(field.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isInIgnoreFields(java.lang.reflect.Field field, Field parentFieldAnnotation) {
|
private static boolean isInIgnoreFields(java.lang.reflect.Field field, Field parentFieldAnnotation) {
|
||||||
if (null != parentFieldAnnotation) {
|
if (null != parentFieldAnnotation) {
|
||||||
String[] ignoreFields = parentFieldAnnotation.ignoreFields();
|
String[] ignoreFields = parentFieldAnnotation.ignoreFields();
|
||||||
return Arrays.asList(ignoreFields).contains(field.getName());
|
return Arrays.asList(ignoreFields).contains(field.getName());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isNestedOrObjectField(java.lang.reflect.Field field) {
|
private static boolean isNestedOrObjectField(java.lang.reflect.Field field) {
|
||||||
Field fieldAnnotation = field.getAnnotation(Field.class);
|
Field fieldAnnotation = field.getAnnotation(Field.class);
|
||||||
return fieldAnnotation != null && (FieldType.Nested == fieldAnnotation.type() || FieldType.Object == fieldAnnotation.type());
|
return fieldAnnotation != null && (FieldType.Nested == fieldAnnotation.type() || FieldType.Object == fieldAnnotation.type());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isGeoPointField(java.lang.reflect.Field field) {
|
private static boolean isGeoPointField(java.lang.reflect.Field field) {
|
||||||
return field.getType() == GeoPoint.class || field.getAnnotation(GeoPointField.class) != null;
|
return field.getType() == GeoPoint.class || field.getAnnotation(GeoPointField.class) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isCompletionField(java.lang.reflect.Field field) {
|
private static boolean isCompletionField(java.lang.reflect.Field field) {
|
||||||
return field.getType() == Completion.class;
|
return field.getType() == Completion.class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
|
|
||||||
public interface ResultsExtractor<T> {
|
public interface ResultsExtractor<T> {
|
||||||
|
|
||||||
T extract(SearchResponse response);
|
T extract(SearchResponse response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResultsMapper
|
* ResultsMapper
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface ResultsMapper extends SearchResultMapper, GetResultMapper, MultiGetResultMapper {
|
public interface ResultsMapper extends SearchResultMapper, GetResultMapper, MultiGetResultMapper {
|
||||||
|
|
||||||
EntityMapper getEntityMapper();
|
EntityMapper getEntityMapper();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+77
-77
@@ -1,77 +1,77 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.convert;
|
package org.springframework.data.elasticsearch.core.convert;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.joda.time.ReadableInstant;
|
import org.joda.time.ReadableInstant;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.joda.time.format.ISODateTimeFormat;
|
import org.joda.time.format.ISODateTimeFormat;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DateTimeConverters
|
* DateTimeConverters
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class DateTimeConverters {
|
public final class DateTimeConverters {
|
||||||
|
|
||||||
private static DateTimeFormatter formatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
|
private static DateTimeFormatter formatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
|
||||||
|
|
||||||
public enum JodaDateTimeConverter implements Converter<ReadableInstant, String> {
|
public enum JodaDateTimeConverter implements Converter<ReadableInstant, String> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convert(ReadableInstant source) {
|
public String convert(ReadableInstant source) {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return formatter.print(source);
|
return formatter.print(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum JodaLocalDateTimeConverter implements Converter<LocalDateTime, String> {
|
public enum JodaLocalDateTimeConverter implements Converter<LocalDateTime, String> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convert(LocalDateTime source) {
|
public String convert(LocalDateTime source) {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return formatter.print(source.toDateTime(DateTimeZone.UTC));
|
return formatter.print(source.toDateTime(DateTimeZone.UTC));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum JavaDateConverter implements Converter<Date, String> {
|
public enum JavaDateConverter implements Converter<Date, String> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convert(Date source) {
|
public String convert(Date source) {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return formatter.print(source.getTime());
|
return formatter.print(source.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-45
@@ -1,45 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.convert;
|
package org.springframework.data.elasticsearch.core.convert;
|
||||||
|
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchConverter
|
* ElasticsearchConverter
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface ElasticsearchConverter {
|
public interface ElasticsearchConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the underlying {@link org.springframework.data.mapping.context.MappingContext} used by the converter.
|
* Returns the underlying {@link org.springframework.data.mapping.context.MappingContext} used by the converter.
|
||||||
*
|
*
|
||||||
* @return never {@literal null}
|
* @return never {@literal null}
|
||||||
*/
|
*/
|
||||||
MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> getMappingContext();
|
MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> getMappingContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the underlying {@link org.springframework.core.convert.ConversionService} used by the converter.
|
* Returns the underlying {@link org.springframework.core.convert.ConversionService} used by the converter.
|
||||||
*
|
*
|
||||||
* @return never {@literal null}.
|
* @return never {@literal null}.
|
||||||
*/
|
*/
|
||||||
ConversionService getConversionService();
|
ConversionService getConversionService();
|
||||||
}
|
}
|
||||||
|
|||||||
+70
-68
@@ -1,68 +1,70 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.convert;
|
package org.springframework.data.elasticsearch.core.convert;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.core.convert.support.DefaultConversionService;
|
import org.springframework.core.convert.support.DefaultConversionService;
|
||||||
import org.springframework.core.convert.support.GenericConversionService;
|
import org.springframework.core.convert.support.GenericConversionService;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MappingElasticsearchConverter
|
* MappingElasticsearchConverter
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
* @author Mark Paluch
|
||||||
|
*/
|
||||||
public class MappingElasticsearchConverter implements ElasticsearchConverter, ApplicationContextAware {
|
public class MappingElasticsearchConverter implements ElasticsearchConverter, ApplicationContextAware {
|
||||||
|
|
||||||
private final MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext;
|
private final MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext;
|
||||||
private final GenericConversionService conversionService;
|
private final GenericConversionService conversionService;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
public MappingElasticsearchConverter(
|
public MappingElasticsearchConverter(
|
||||||
MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
|
MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
|
||||||
Assert.notNull(mappingContext);
|
|
||||||
this.mappingContext = mappingContext;
|
Assert.notNull(mappingContext, "MappingContext must not be null!");
|
||||||
this.conversionService = new DefaultConversionService();
|
|
||||||
}
|
this.mappingContext = mappingContext;
|
||||||
|
this.conversionService = new DefaultConversionService();
|
||||||
@Override
|
}
|
||||||
public MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> getMappingContext() {
|
|
||||||
return mappingContext;
|
@Override
|
||||||
}
|
public MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> getMappingContext() {
|
||||||
|
return mappingContext;
|
||||||
@Override
|
}
|
||||||
public ConversionService getConversionService() {
|
|
||||||
return this.conversionService;
|
@Override
|
||||||
}
|
public ConversionService getConversionService() {
|
||||||
|
return this.conversionService;
|
||||||
@Override
|
}
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
||||||
this.applicationContext = applicationContext;
|
@Override
|
||||||
if (mappingContext instanceof ApplicationContextAware) {
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
((ApplicationContextAware) mappingContext).setApplicationContext(applicationContext);
|
this.applicationContext = applicationContext;
|
||||||
}
|
if (mappingContext instanceof ApplicationContextAware) {
|
||||||
}
|
((ApplicationContextAware) mappingContext).setApplicationContext(applicationContext);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -47,4 +47,4 @@ public abstract class AbstractFacetRequest implements FacetRequest {
|
|||||||
public boolean applyQueryFilter() {
|
public boolean applyQueryFilter() {
|
||||||
return applyQueryFilter;
|
return applyQueryFilter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -70,4 +70,4 @@ public class HistogramFacetRequest extends AbstractFacetRequest {
|
|||||||
|
|
||||||
return dateHistogramBuilder;
|
return dateHistogramBuilder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -55,4 +55,4 @@ public class HistogramFacetRequestBuilder {
|
|||||||
result.setApplyQueryFilter(true);
|
result.setApplyQueryFilter(true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -82,4 +82,4 @@ public class RangeFacetRequestBuilder {
|
|||||||
public FacetRequest build() {
|
public FacetRequest build() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -50,4 +50,4 @@ public class StatisticalFacetRequest extends AbstractFacetRequest {
|
|||||||
Assert.isTrue(StringUtils.isNotBlank(field) && fields == null, "Please select field or fields on which to build the facets !!!");
|
Assert.isTrue(StringUtils.isNotBlank(field) && fields == null, "Please select field or fields on which to build the facets !!!");
|
||||||
return AggregationBuilders.extendedStats(getName()).field(field);
|
return AggregationBuilders.extendedStats(getName()).field(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -49,4 +49,4 @@ public class StatisticalFacetRequestBuilder {
|
|||||||
public FacetRequest build() {
|
public FacetRequest build() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -104,4 +104,4 @@ public class TermFacetRequest extends AbstractFacetRequest {
|
|||||||
|
|
||||||
return termsBuilder;
|
return termsBuilder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -85,4 +85,4 @@ public class TermFacetRequestBuilder {
|
|||||||
public FacetRequest build() {
|
public FacetRequest build() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+52
-52
@@ -1,52 +1,52 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.mapping;
|
package org.springframework.data.elasticsearch.core.mapping;
|
||||||
|
|
||||||
import org.springframework.data.mapping.PersistentEntity;
|
import org.springframework.data.mapping.PersistentEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchPersistentEntity
|
* ElasticsearchPersistentEntity
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, ElasticsearchPersistentProperty> {
|
public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, ElasticsearchPersistentProperty> {
|
||||||
|
|
||||||
String getIndexName();
|
String getIndexName();
|
||||||
|
|
||||||
String getIndexType();
|
String getIndexType();
|
||||||
|
|
||||||
short getShards();
|
short getShards();
|
||||||
|
|
||||||
short getReplicas();
|
short getReplicas();
|
||||||
|
|
||||||
boolean isUseServerConfiguration();
|
boolean isUseServerConfiguration();
|
||||||
|
|
||||||
String getRefreshInterval();
|
String getRefreshInterval();
|
||||||
|
|
||||||
String getIndexStoreType();
|
String getIndexStoreType();
|
||||||
|
|
||||||
ElasticsearchPersistentProperty getVersionProperty();
|
ElasticsearchPersistentProperty getVersionProperty();
|
||||||
|
|
||||||
String getParentType();
|
String getParentType();
|
||||||
|
|
||||||
ElasticsearchPersistentProperty getParentIdProperty();
|
ElasticsearchPersistentProperty getParentIdProperty();
|
||||||
|
|
||||||
String settingPath();
|
String settingPath();
|
||||||
|
|
||||||
boolean isCreateIndexAndMapping();
|
boolean isCreateIndexAndMapping();
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-40
@@ -1,40 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.mapping;
|
package org.springframework.data.elasticsearch.core.mapping;
|
||||||
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.data.mapping.PersistentProperty;
|
import org.springframework.data.mapping.PersistentProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchPersistentProperty
|
* ElasticsearchPersistentProperty
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface ElasticsearchPersistentProperty extends PersistentProperty<ElasticsearchPersistentProperty> {
|
public interface ElasticsearchPersistentProperty extends PersistentProperty<ElasticsearchPersistentProperty> {
|
||||||
|
|
||||||
String getFieldName();
|
String getFieldName();
|
||||||
|
|
||||||
public enum PropertyToFieldNameConverter implements Converter<ElasticsearchPersistentProperty, String> {
|
public enum PropertyToFieldNameConverter implements Converter<ElasticsearchPersistentProperty, String> {
|
||||||
|
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
public String convert(ElasticsearchPersistentProperty source) {
|
public String convert(ElasticsearchPersistentProperty source) {
|
||||||
return source.getFieldName();
|
return source.getFieldName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+60
-60
@@ -1,60 +1,60 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.mapping;
|
package org.springframework.data.elasticsearch.core.mapping;
|
||||||
|
|
||||||
import java.beans.PropertyDescriptor;
|
import java.beans.PropertyDescriptor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.data.mapping.context.AbstractMappingContext;
|
import org.springframework.data.mapping.context.AbstractMappingContext;
|
||||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SimpleElasticsearchMappingContext
|
* SimpleElasticsearchMappingContext
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SimpleElasticsearchMappingContext extends
|
public class SimpleElasticsearchMappingContext extends
|
||||||
AbstractMappingContext<SimpleElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> implements ApplicationContextAware {
|
AbstractMappingContext<SimpleElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> implements ApplicationContextAware {
|
||||||
|
|
||||||
private ApplicationContext context;
|
private ApplicationContext context;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <T> SimpleElasticsearchPersistentEntity<?> createPersistentEntity(TypeInformation<T> typeInformation) {
|
protected <T> SimpleElasticsearchPersistentEntity<?> createPersistentEntity(TypeInformation<T> typeInformation) {
|
||||||
final SimpleElasticsearchPersistentEntity<T> persistentEntity =
|
final SimpleElasticsearchPersistentEntity<T> persistentEntity =
|
||||||
new SimpleElasticsearchPersistentEntity<T>(typeInformation);
|
new SimpleElasticsearchPersistentEntity<T>(typeInformation);
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
persistentEntity.setApplicationContext(context);
|
persistentEntity.setApplicationContext(context);
|
||||||
}
|
}
|
||||||
return persistentEntity;
|
return persistentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ElasticsearchPersistentProperty createPersistentProperty(Field field, PropertyDescriptor descriptor,
|
protected ElasticsearchPersistentProperty createPersistentProperty(Field field, PropertyDescriptor descriptor,
|
||||||
SimpleElasticsearchPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
|
SimpleElasticsearchPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
|
||||||
return new SimpleElasticsearchPersistentProperty(field, descriptor, owner, simpleTypeHolder);
|
return new SimpleElasticsearchPersistentProperty(field, descriptor, owner, simpleTypeHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationContext(ApplicationContext context) throws BeansException {
|
public void setApplicationContext(ApplicationContext context) throws BeansException {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+170
-170
@@ -1,170 +1,170 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.mapping;
|
package org.springframework.data.elasticsearch.core.mapping;
|
||||||
|
|
||||||
import static org.springframework.util.StringUtils.*;
|
import static org.springframework.util.StringUtils.*;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.context.expression.BeanFactoryAccessor;
|
import org.springframework.context.expression.BeanFactoryAccessor;
|
||||||
import org.springframework.context.expression.BeanFactoryResolver;
|
import org.springframework.context.expression.BeanFactoryResolver;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Parent;
|
import org.springframework.data.elasticsearch.annotations.Parent;
|
||||||
import org.springframework.data.elasticsearch.annotations.Setting;
|
import org.springframework.data.elasticsearch.annotations.Setting;
|
||||||
import org.springframework.data.mapping.model.BasicPersistentEntity;
|
import org.springframework.data.mapping.model.BasicPersistentEntity;
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.expression.Expression;
|
import org.springframework.expression.Expression;
|
||||||
import org.springframework.expression.ParserContext;
|
import org.springframework.expression.ParserContext;
|
||||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentEntity} implementation holding
|
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentEntity} implementation holding
|
||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntity<T, ElasticsearchPersistentProperty>
|
public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntity<T, ElasticsearchPersistentProperty>
|
||||||
implements ElasticsearchPersistentEntity<T>, ApplicationContextAware {
|
implements ElasticsearchPersistentEntity<T>, ApplicationContextAware {
|
||||||
|
|
||||||
private final StandardEvaluationContext context;
|
private final StandardEvaluationContext context;
|
||||||
private final SpelExpressionParser parser;
|
private final SpelExpressionParser parser;
|
||||||
|
|
||||||
private String indexName;
|
private String indexName;
|
||||||
private String indexType;
|
private String indexType;
|
||||||
private boolean useServerConfiguration;
|
private boolean useServerConfiguration;
|
||||||
private short shards;
|
private short shards;
|
||||||
private short replicas;
|
private short replicas;
|
||||||
private String refreshInterval;
|
private String refreshInterval;
|
||||||
private String indexStoreType;
|
private String indexStoreType;
|
||||||
private String parentType;
|
private String parentType;
|
||||||
private ElasticsearchPersistentProperty parentIdProperty;
|
private ElasticsearchPersistentProperty parentIdProperty;
|
||||||
private String settingPath;
|
private String settingPath;
|
||||||
private boolean createIndexAndMapping;
|
private boolean createIndexAndMapping;
|
||||||
|
|
||||||
public SimpleElasticsearchPersistentEntity(TypeInformation<T> typeInformation) {
|
public SimpleElasticsearchPersistentEntity(TypeInformation<T> typeInformation) {
|
||||||
super(typeInformation);
|
super(typeInformation);
|
||||||
this.context = new StandardEvaluationContext();
|
this.context = new StandardEvaluationContext();
|
||||||
this.parser = new SpelExpressionParser();
|
this.parser = new SpelExpressionParser();
|
||||||
|
|
||||||
Class<T> clazz = typeInformation.getType();
|
Class<T> clazz = typeInformation.getType();
|
||||||
if (clazz.isAnnotationPresent(Document.class)) {
|
if (clazz.isAnnotationPresent(Document.class)) {
|
||||||
Document document = clazz.getAnnotation(Document.class);
|
Document document = clazz.getAnnotation(Document.class);
|
||||||
Assert.hasText(document.indexName(),
|
Assert.hasText(document.indexName(),
|
||||||
" Unknown indexName. Make sure the indexName is defined. e.g @Document(indexName=\"foo\")");
|
" Unknown indexName. Make sure the indexName is defined. e.g @Document(indexName=\"foo\")");
|
||||||
this.indexName = document.indexName();
|
this.indexName = document.indexName();
|
||||||
this.indexType = hasText(document.type()) ? document.type() : clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
|
this.indexType = hasText(document.type()) ? document.type() : clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
|
||||||
this.useServerConfiguration = document.useServerConfiguration();
|
this.useServerConfiguration = document.useServerConfiguration();
|
||||||
this.shards = document.shards();
|
this.shards = document.shards();
|
||||||
this.replicas = document.replicas();
|
this.replicas = document.replicas();
|
||||||
this.refreshInterval = document.refreshInterval();
|
this.refreshInterval = document.refreshInterval();
|
||||||
this.indexStoreType = document.indexStoreType();
|
this.indexStoreType = document.indexStoreType();
|
||||||
this.createIndexAndMapping = document.createIndex();
|
this.createIndexAndMapping = document.createIndex();
|
||||||
}
|
}
|
||||||
if (clazz.isAnnotationPresent(Setting.class)) {
|
if (clazz.isAnnotationPresent(Setting.class)) {
|
||||||
this.settingPath = typeInformation.getType().getAnnotation(Setting.class).settingPath();
|
this.settingPath = typeInformation.getType().getAnnotation(Setting.class).settingPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
context.addPropertyAccessor(new BeanFactoryAccessor());
|
context.addPropertyAccessor(new BeanFactoryAccessor());
|
||||||
context.setBeanResolver(new BeanFactoryResolver(applicationContext));
|
context.setBeanResolver(new BeanFactoryResolver(applicationContext));
|
||||||
context.setRootObject(applicationContext);
|
context.setRootObject(applicationContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIndexName() {
|
public String getIndexName() {
|
||||||
Expression expression = parser.parseExpression(indexName, ParserContext.TEMPLATE_EXPRESSION);
|
Expression expression = parser.parseExpression(indexName, ParserContext.TEMPLATE_EXPRESSION);
|
||||||
return expression.getValue(context, String.class);
|
return expression.getValue(context, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIndexType() {
|
public String getIndexType() {
|
||||||
Expression expression = parser.parseExpression(indexType, ParserContext.TEMPLATE_EXPRESSION);
|
Expression expression = parser.parseExpression(indexType, ParserContext.TEMPLATE_EXPRESSION);
|
||||||
return expression.getValue(context, String.class);
|
return expression.getValue(context, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIndexStoreType() {
|
public String getIndexStoreType() {
|
||||||
return indexStoreType;
|
return indexStoreType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short getShards() {
|
public short getShards() {
|
||||||
return shards;
|
return shards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short getReplicas() {
|
public short getReplicas() {
|
||||||
return replicas;
|
return replicas;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUseServerConfiguration() {
|
public boolean isUseServerConfiguration() {
|
||||||
return useServerConfiguration;
|
return useServerConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRefreshInterval() {
|
public String getRefreshInterval() {
|
||||||
return refreshInterval;
|
return refreshInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParentType() {
|
public String getParentType() {
|
||||||
return parentType;
|
return parentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElasticsearchPersistentProperty getParentIdProperty() {
|
public ElasticsearchPersistentProperty getParentIdProperty() {
|
||||||
return parentIdProperty;
|
return parentIdProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String settingPath() {
|
public String settingPath() {
|
||||||
return settingPath;
|
return settingPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCreateIndexAndMapping() {
|
public boolean isCreateIndexAndMapping() {
|
||||||
return createIndexAndMapping;
|
return createIndexAndMapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPersistentProperty(ElasticsearchPersistentProperty property) {
|
public void addPersistentProperty(ElasticsearchPersistentProperty property) {
|
||||||
super.addPersistentProperty(property);
|
super.addPersistentProperty(property);
|
||||||
|
|
||||||
if (property.getField() != null) {
|
if (property.getField() != null) {
|
||||||
Parent parent = property.getField().getAnnotation(Parent.class);
|
Parent parent = property.getField().getAnnotation(Parent.class);
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
Assert.isNull(this.parentIdProperty, "Only one field can hold a @Parent annotation");
|
Assert.isNull(this.parentIdProperty, "Only one field can hold a @Parent annotation");
|
||||||
Assert.isNull(this.parentType, "Only one field can hold a @Parent annotation");
|
Assert.isNull(this.parentType, "Only one field can hold a @Parent annotation");
|
||||||
Assert.isTrue(property.getType() == String.class, "Parent ID property should be String");
|
Assert.isTrue(property.getType() == String.class, "Parent ID property should be String");
|
||||||
this.parentIdProperty = property;
|
this.parentIdProperty = property;
|
||||||
this.parentType = parent.type();
|
this.parentType = parent.type();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property.isVersionProperty()) {
|
if (property.isVersionProperty()) {
|
||||||
Assert.isTrue(property.getType() == Long.class, "Version property should be Long");
|
Assert.isTrue(property.getType() == Long.class, "Version property should be Long");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-65
@@ -1,65 +1,65 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.mapping;
|
package org.springframework.data.elasticsearch.core.mapping;
|
||||||
|
|
||||||
import java.beans.PropertyDescriptor;
|
import java.beans.PropertyDescriptor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.data.mapping.Association;
|
import org.springframework.data.mapping.Association;
|
||||||
import org.springframework.data.mapping.PersistentEntity;
|
import org.springframework.data.mapping.PersistentEntity;
|
||||||
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
|
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
|
||||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentProperty} implementation processing
|
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentProperty} implementation processing
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class SimpleElasticsearchPersistentProperty extends
|
public class SimpleElasticsearchPersistentProperty extends
|
||||||
AnnotationBasedPersistentProperty<ElasticsearchPersistentProperty> implements ElasticsearchPersistentProperty {
|
AnnotationBasedPersistentProperty<ElasticsearchPersistentProperty> implements ElasticsearchPersistentProperty {
|
||||||
|
|
||||||
private static final Set<Class<?>> SUPPORTED_ID_TYPES = new HashSet<Class<?>>();
|
private static final Set<Class<?>> SUPPORTED_ID_TYPES = new HashSet<Class<?>>();
|
||||||
private static final Set<String> SUPPORTED_ID_PROPERTY_NAMES = new HashSet<String>();
|
private static final Set<String> SUPPORTED_ID_PROPERTY_NAMES = new HashSet<String>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SUPPORTED_ID_TYPES.add(String.class);
|
SUPPORTED_ID_TYPES.add(String.class);
|
||||||
SUPPORTED_ID_PROPERTY_NAMES.add("id");
|
SUPPORTED_ID_PROPERTY_NAMES.add("id");
|
||||||
SUPPORTED_ID_PROPERTY_NAMES.add("documentId");
|
SUPPORTED_ID_PROPERTY_NAMES.add("documentId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleElasticsearchPersistentProperty(Field field, PropertyDescriptor propertyDescriptor,
|
public SimpleElasticsearchPersistentProperty(Field field, PropertyDescriptor propertyDescriptor,
|
||||||
PersistentEntity<?, ElasticsearchPersistentProperty> owner, SimpleTypeHolder simpleTypeHolder) {
|
PersistentEntity<?, ElasticsearchPersistentProperty> owner, SimpleTypeHolder simpleTypeHolder) {
|
||||||
super(field, propertyDescriptor, owner, simpleTypeHolder);
|
super(field, propertyDescriptor, owner, simpleTypeHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFieldName() {
|
public String getFieldName() {
|
||||||
return field.getName();
|
return field.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isIdProperty() {
|
public boolean isIdProperty() {
|
||||||
return super.isIdProperty() || (field != null ? SUPPORTED_ID_PROPERTY_NAMES.contains(getFieldName()) : false);
|
return super.isIdProperty() || (field != null ? SUPPORTED_ID_PROPERTY_NAMES.contains(getFieldName()) : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Association<ElasticsearchPersistentProperty> createAssociation() {
|
protected Association<ElasticsearchPersistentProperty> createAssociation() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -29,6 +29,7 @@ import org.springframework.util.Assert;
|
|||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
abstract class AbstractQuery implements Query {
|
abstract class AbstractQuery implements Query {
|
||||||
|
|
||||||
@@ -55,7 +56,9 @@ abstract class AbstractQuery implements Query {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final <T extends Query> T setPageable(Pageable pageable) {
|
public final <T extends Query> T setPageable(Pageable pageable) {
|
||||||
Assert.notNull(pageable);
|
|
||||||
|
Assert.notNull(pageable, "Pageable must not be null!");
|
||||||
|
|
||||||
this.pageable = pageable;
|
this.pageable = pageable;
|
||||||
return (T) this.addSort(pageable.getSort());
|
return (T) this.addSort(pageable.getSort());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,81 +1,81 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class AliasBuilder {
|
public class AliasBuilder {
|
||||||
|
|
||||||
private String indexName;
|
private String indexName;
|
||||||
private String aliasName;
|
private String aliasName;
|
||||||
private QueryBuilder filterBuilder;
|
private QueryBuilder filterBuilder;
|
||||||
private Map<String, Object> filter;
|
private Map<String, Object> filter;
|
||||||
private String searchRouting;
|
private String searchRouting;
|
||||||
private String indexRouting;
|
private String indexRouting;
|
||||||
private String routing;
|
private String routing;
|
||||||
|
|
||||||
public AliasBuilder withIndexName(String indexName) {
|
public AliasBuilder withIndexName(String indexName) {
|
||||||
this.indexName = indexName;
|
this.indexName = indexName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasBuilder withAliasName(String aliasName) {
|
public AliasBuilder withAliasName(String aliasName) {
|
||||||
this.aliasName = aliasName;
|
this.aliasName = aliasName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasBuilder withFilterBuilder(QueryBuilder filterBuilder) {
|
public AliasBuilder withFilterBuilder(QueryBuilder filterBuilder) {
|
||||||
this.filterBuilder = filterBuilder;
|
this.filterBuilder = filterBuilder;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasBuilder withFilter(Map<String, Object> filter) {
|
public AliasBuilder withFilter(Map<String, Object> filter) {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasBuilder withSearchRouting(String searchRouting) {
|
public AliasBuilder withSearchRouting(String searchRouting) {
|
||||||
this.searchRouting = searchRouting;
|
this.searchRouting = searchRouting;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasBuilder withIndexRouting(String indexRouting) {
|
public AliasBuilder withIndexRouting(String indexRouting) {
|
||||||
this.indexRouting = indexRouting;
|
this.indexRouting = indexRouting;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasBuilder withRouting(String routing) {
|
public AliasBuilder withRouting(String routing) {
|
||||||
this.routing = routing;
|
this.routing = routing;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasQuery build() {
|
public AliasQuery build() {
|
||||||
AliasQuery aliasQuery = new AliasQuery();
|
AliasQuery aliasQuery = new AliasQuery();
|
||||||
aliasQuery.setIndexName(indexName);
|
aliasQuery.setIndexName(indexName);
|
||||||
aliasQuery.setAliasName(aliasName);
|
aliasQuery.setAliasName(aliasName);
|
||||||
aliasQuery.setFilterBuilder(filterBuilder);
|
aliasQuery.setFilterBuilder(filterBuilder);
|
||||||
aliasQuery.setFilter(filter);
|
aliasQuery.setFilter(filter);
|
||||||
aliasQuery.setSearchRouting(searchRouting);
|
aliasQuery.setSearchRouting(searchRouting);
|
||||||
aliasQuery.setIndexRouting(indexRouting);
|
aliasQuery.setIndexRouting(indexRouting);
|
||||||
aliasQuery.setRouting(routing);
|
aliasQuery.setRouting(routing);
|
||||||
return aliasQuery;
|
return aliasQuery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,92 +1,92 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AliasQuery is useful for creating new alias or deleting existing ones
|
* AliasQuery is useful for creating new alias or deleting existing ones
|
||||||
*
|
*
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class AliasQuery {
|
public class AliasQuery {
|
||||||
|
|
||||||
private String indexName;
|
private String indexName;
|
||||||
private String aliasName;
|
private String aliasName;
|
||||||
private QueryBuilder filterBuilder;
|
private QueryBuilder filterBuilder;
|
||||||
private Map<String, Object> filter;
|
private Map<String, Object> filter;
|
||||||
private String searchRouting;
|
private String searchRouting;
|
||||||
private String indexRouting;
|
private String indexRouting;
|
||||||
private String routing;
|
private String routing;
|
||||||
|
|
||||||
public String getIndexName() {
|
public String getIndexName() {
|
||||||
return indexName;
|
return indexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndexName(String indexName) {
|
public void setIndexName(String indexName) {
|
||||||
this.indexName = indexName;
|
this.indexName = indexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAliasName() {
|
public String getAliasName() {
|
||||||
return aliasName;
|
return aliasName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAliasName(String aliasName) {
|
public void setAliasName(String aliasName) {
|
||||||
this.aliasName = aliasName;
|
this.aliasName = aliasName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryBuilder getFilterBuilder() {
|
public QueryBuilder getFilterBuilder() {
|
||||||
return filterBuilder;
|
return filterBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilterBuilder(QueryBuilder filterBuilder) {
|
public void setFilterBuilder(QueryBuilder filterBuilder) {
|
||||||
this.filterBuilder = filterBuilder;
|
this.filterBuilder = filterBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getFilter() {
|
public Map<String, Object> getFilter() {
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilter(Map<String, Object> filter) {
|
public void setFilter(Map<String, Object> filter) {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSearchRouting() {
|
public String getSearchRouting() {
|
||||||
return searchRouting;
|
return searchRouting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSearchRouting(String searchRouting) {
|
public void setSearchRouting(String searchRouting) {
|
||||||
this.searchRouting = searchRouting;
|
this.searchRouting = searchRouting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndexRouting() {
|
public String getIndexRouting() {
|
||||||
return indexRouting;
|
return indexRouting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndexRouting(String indexRouting) {
|
public void setIndexRouting(String indexRouting) {
|
||||||
this.indexRouting = indexRouting;
|
this.indexRouting = indexRouting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRouting() {
|
public String getRouting() {
|
||||||
return routing;
|
return routing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRouting(String routing) {
|
public void setRouting(String routing) {
|
||||||
this.routing = routing;
|
this.routing = routing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+80
-80
@@ -1,80 +1,80 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CriteriaQuery
|
* CriteriaQuery
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class CriteriaQuery extends AbstractQuery {
|
public class CriteriaQuery extends AbstractQuery {
|
||||||
|
|
||||||
private Criteria criteria;
|
private Criteria criteria;
|
||||||
|
|
||||||
private CriteriaQuery() {
|
private CriteriaQuery() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CriteriaQuery(Criteria criteria) {
|
public CriteriaQuery(Criteria criteria) {
|
||||||
this(criteria, null);
|
this(criteria, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CriteriaQuery(Criteria criteria, Pageable pageable) {
|
public CriteriaQuery(Criteria criteria, Pageable pageable) {
|
||||||
this.criteria = criteria;
|
this.criteria = criteria;
|
||||||
this.pageable = pageable;
|
this.pageable = pageable;
|
||||||
if (pageable != null) {
|
if (pageable != null) {
|
||||||
this.addSort(pageable.getSort());
|
this.addSort(pageable.getSort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Query fromQuery(CriteriaQuery source) {
|
public static final Query fromQuery(CriteriaQuery source) {
|
||||||
return fromQuery(source, new CriteriaQuery());
|
return fromQuery(source, new CriteriaQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends CriteriaQuery> T fromQuery(CriteriaQuery source, T destination) {
|
public static <T extends CriteriaQuery> T fromQuery(CriteriaQuery source, T destination) {
|
||||||
if (source == null || destination == null) {
|
if (source == null || destination == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source.getCriteria() != null) {
|
if (source.getCriteria() != null) {
|
||||||
destination.addCriteria(source.getCriteria());
|
destination.addCriteria(source.getCriteria());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source.getSort() != null) {
|
if (source.getSort() != null) {
|
||||||
destination.addSort(source.getSort());
|
destination.addSort(source.getSort());
|
||||||
}
|
}
|
||||||
|
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final <T extends CriteriaQuery> T addCriteria(Criteria criteria) {
|
public final <T extends CriteriaQuery> T addCriteria(Criteria criteria) {
|
||||||
Assert.notNull(criteria, "Cannot add null criteria.");
|
Assert.notNull(criteria, "Cannot add null criteria.");
|
||||||
if (this.criteria == null) {
|
if (this.criteria == null) {
|
||||||
this.criteria = criteria;
|
this.criteria = criteria;
|
||||||
} else {
|
} else {
|
||||||
this.criteria.and(criteria);
|
this.criteria.and(criteria);
|
||||||
}
|
}
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria getCriteria() {
|
public Criteria getCriteria() {
|
||||||
return this.criteria;
|
return this.criteria;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,73 +1,73 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteQuery
|
* DeleteQuery
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class DeleteQuery {
|
public class DeleteQuery {
|
||||||
|
|
||||||
private QueryBuilder query;
|
private QueryBuilder query;
|
||||||
private String index;
|
private String index;
|
||||||
private String type;
|
private String type;
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
private Long scrollTimeInMillis;
|
private Long scrollTimeInMillis;
|
||||||
|
|
||||||
public QueryBuilder getQuery() {
|
public QueryBuilder getQuery() {
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQuery(QueryBuilder query) {
|
public void setQuery(QueryBuilder query) {
|
||||||
this.query = query;
|
this.query = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndex() {
|
public String getIndex() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndex(String index) {
|
public void setIndex(String index) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPageSize() {
|
public Integer getPageSize() {
|
||||||
return pageSize;
|
return pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPageSize(Integer pageSize) {
|
public void setPageSize(Integer pageSize) {
|
||||||
this.pageSize = pageSize;
|
this.pageSize = pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getScrollTimeInMillis() {
|
public Long getScrollTimeInMillis() {
|
||||||
return scrollTimeInMillis;
|
return scrollTimeInMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScrollTimeInMillis(Long scrollTimeInMillis) {
|
public void setScrollTimeInMillis(Long scrollTimeInMillis) {
|
||||||
this.scrollTimeInMillis = scrollTimeInMillis;
|
this.scrollTimeInMillis = scrollTimeInMillis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 the original author or authors.
|
* Copyright 2016-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 the original author or authors.
|
* Copyright 2016-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a Field that can be used within a Criteria.
|
* Defines a Field that can be used within a Criteria.
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public interface Field {
|
public interface Field {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the field used in schema.xml of elasticsearch server
|
* Get the name of the field used in schema.xml of elasticsearch server
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getName();
|
String getName();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetQuery
|
* GetQuery
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class GetQuery {
|
public class GetQuery {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 the original author or authors.
|
* Copyright 2016-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,90 +1,90 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IndexQuery
|
* IndexQuery
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class IndexQuery {
|
public class IndexQuery {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private Object object;
|
private Object object;
|
||||||
private Long version;
|
private Long version;
|
||||||
private String indexName;
|
private String indexName;
|
||||||
private String type;
|
private String type;
|
||||||
private String source;
|
private String source;
|
||||||
private String parentId;
|
private String parentId;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getObject() {
|
public Object getObject() {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setObject(Object object) {
|
public void setObject(Object object) {
|
||||||
this.object = object;
|
this.object = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getVersion() {
|
public Long getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVersion(Long version) {
|
public void setVersion(Long version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndexName() {
|
public String getIndexName() {
|
||||||
return indexName;
|
return indexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndexName(String indexName) {
|
public void setIndexName(String indexName) {
|
||||||
this.indexName = indexName;
|
this.indexName = indexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSource() {
|
public String getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(String source) {
|
public void setSource(String source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParentId() {
|
public String getParentId() {
|
||||||
return parentId;
|
return parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentId(String parentId) {
|
public void setParentId(String parentId) {
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 the original author or authors.
|
* Copyright 2014-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
+188
-188
@@ -1,188 +1,188 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import static java.util.Collections.addAll;
|
import static java.util.Collections.addAll;
|
||||||
import static org.springframework.data.elasticsearch.core.query.AbstractQuery.*;
|
import static org.springframework.data.elasticsearch.core.query.AbstractQuery.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MoreLikeThisQuery
|
* MoreLikeThisQuery
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MoreLikeThisQuery {
|
public class MoreLikeThisQuery {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String indexName;
|
private String indexName;
|
||||||
private String type;
|
private String type;
|
||||||
private List<String> searchIndices = new ArrayList<String>();
|
private List<String> searchIndices = new ArrayList<String>();
|
||||||
private List<String> searchTypes = new ArrayList<String>();
|
private List<String> searchTypes = new ArrayList<String>();
|
||||||
private List<String> fields = new ArrayList<String>();
|
private List<String> fields = new ArrayList<String>();
|
||||||
private String routing;
|
private String routing;
|
||||||
private Float percentTermsToMatch;
|
private Float percentTermsToMatch;
|
||||||
private Integer minTermFreq;
|
private Integer minTermFreq;
|
||||||
private Integer maxQueryTerms;
|
private Integer maxQueryTerms;
|
||||||
private List<String> stopWords = new ArrayList<String>();
|
private List<String> stopWords = new ArrayList<String>();
|
||||||
private Integer minDocFreq;
|
private Integer minDocFreq;
|
||||||
private Integer maxDocFreq;
|
private Integer maxDocFreq;
|
||||||
private Integer minWordLen;
|
private Integer minWordLen;
|
||||||
private Integer maxWordLen;
|
private Integer maxWordLen;
|
||||||
private Float boostTerms;
|
private Float boostTerms;
|
||||||
private Pageable pageable = DEFAULT_PAGE;
|
private Pageable pageable = DEFAULT_PAGE;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndexName() {
|
public String getIndexName() {
|
||||||
return indexName;
|
return indexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndexName(String indexName) {
|
public void setIndexName(String indexName) {
|
||||||
this.indexName = indexName;
|
this.indexName = indexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSearchIndices() {
|
public List<String> getSearchIndices() {
|
||||||
return searchIndices;
|
return searchIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSearchIndices(String... searchIndices) {
|
public void addSearchIndices(String... searchIndices) {
|
||||||
addAll(this.searchIndices, searchIndices);
|
addAll(this.searchIndices, searchIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSearchTypes() {
|
public List<String> getSearchTypes() {
|
||||||
return searchTypes;
|
return searchTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSearchTypes(String... searchTypes) {
|
public void addSearchTypes(String... searchTypes) {
|
||||||
addAll(this.searchTypes, searchTypes);
|
addAll(this.searchTypes, searchTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getFields() {
|
public List<String> getFields() {
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFields(String... fields) {
|
public void addFields(String... fields) {
|
||||||
addAll(this.fields, fields);
|
addAll(this.fields, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRouting() {
|
public String getRouting() {
|
||||||
return routing;
|
return routing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRouting(String routing) {
|
public void setRouting(String routing) {
|
||||||
this.routing = routing;
|
this.routing = routing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getPercentTermsToMatch() {
|
public Float getPercentTermsToMatch() {
|
||||||
return percentTermsToMatch;
|
return percentTermsToMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercentTermsToMatch(Float percentTermsToMatch) {
|
public void setPercentTermsToMatch(Float percentTermsToMatch) {
|
||||||
this.percentTermsToMatch = percentTermsToMatch;
|
this.percentTermsToMatch = percentTermsToMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMinTermFreq() {
|
public Integer getMinTermFreq() {
|
||||||
return minTermFreq;
|
return minTermFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinTermFreq(Integer minTermFreq) {
|
public void setMinTermFreq(Integer minTermFreq) {
|
||||||
this.minTermFreq = minTermFreq;
|
this.minTermFreq = minTermFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMaxQueryTerms() {
|
public Integer getMaxQueryTerms() {
|
||||||
return maxQueryTerms;
|
return maxQueryTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxQueryTerms(Integer maxQueryTerms) {
|
public void setMaxQueryTerms(Integer maxQueryTerms) {
|
||||||
this.maxQueryTerms = maxQueryTerms;
|
this.maxQueryTerms = maxQueryTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getStopWords() {
|
public List<String> getStopWords() {
|
||||||
return stopWords;
|
return stopWords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStopWords(String... stopWords) {
|
public void addStopWords(String... stopWords) {
|
||||||
addAll(this.stopWords, stopWords);
|
addAll(this.stopWords, stopWords);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMinDocFreq() {
|
public Integer getMinDocFreq() {
|
||||||
return minDocFreq;
|
return minDocFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinDocFreq(Integer minDocFreq) {
|
public void setMinDocFreq(Integer minDocFreq) {
|
||||||
this.minDocFreq = minDocFreq;
|
this.minDocFreq = minDocFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMaxDocFreq() {
|
public Integer getMaxDocFreq() {
|
||||||
return maxDocFreq;
|
return maxDocFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxDocFreq(Integer maxDocFreq) {
|
public void setMaxDocFreq(Integer maxDocFreq) {
|
||||||
this.maxDocFreq = maxDocFreq;
|
this.maxDocFreq = maxDocFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMinWordLen() {
|
public Integer getMinWordLen() {
|
||||||
return minWordLen;
|
return minWordLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinWordLen(Integer minWordLen) {
|
public void setMinWordLen(Integer minWordLen) {
|
||||||
this.minWordLen = minWordLen;
|
this.minWordLen = minWordLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMaxWordLen() {
|
public Integer getMaxWordLen() {
|
||||||
return maxWordLen;
|
return maxWordLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxWordLen(Integer maxWordLen) {
|
public void setMaxWordLen(Integer maxWordLen) {
|
||||||
this.maxWordLen = maxWordLen;
|
this.maxWordLen = maxWordLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getBoostTerms() {
|
public Float getBoostTerms() {
|
||||||
return boostTerms;
|
return boostTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBoostTerms(Float boostTerms) {
|
public void setBoostTerms(Float boostTerms) {
|
||||||
this.boostTerms = boostTerms;
|
this.boostTerms = boostTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pageable getPageable() {
|
public Pageable getPageable() {
|
||||||
return pageable;
|
return pageable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPageable(Pageable pageable) {
|
public void setPageable(Pageable pageable) {
|
||||||
this.pageable = pageable;
|
this.pageable = pageable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+140
-140
@@ -1,140 +1,140 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
||||||
import org.elasticsearch.search.highlight.HighlightBuilder;
|
import org.elasticsearch.search.highlight.HighlightBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilder;
|
import org.elasticsearch.search.sort.SortBuilder;
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeSearchQuery
|
* NativeSearchQuery
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
public class NativeSearchQuery extends AbstractQuery implements SearchQuery {
|
public class NativeSearchQuery extends AbstractQuery implements SearchQuery {
|
||||||
|
|
||||||
private QueryBuilder query;
|
private QueryBuilder query;
|
||||||
private QueryBuilder filter;
|
private QueryBuilder filter;
|
||||||
private List<SortBuilder> sorts;
|
private List<SortBuilder> sorts;
|
||||||
private final List<ScriptField> scriptFields = new ArrayList<ScriptField>();
|
private final List<ScriptField> scriptFields = new ArrayList<ScriptField>();
|
||||||
private List<FacetRequest> facets;
|
private List<FacetRequest> facets;
|
||||||
private List<AbstractAggregationBuilder> aggregations;
|
private List<AbstractAggregationBuilder> aggregations;
|
||||||
private HighlightBuilder.Field[] highlightFields;
|
private HighlightBuilder.Field[] highlightFields;
|
||||||
private List<IndexBoost> indicesBoost;
|
private List<IndexBoost> indicesBoost;
|
||||||
|
|
||||||
|
|
||||||
public NativeSearchQuery(QueryBuilder query) {
|
public NativeSearchQuery(QueryBuilder query) {
|
||||||
this.query = query;
|
this.query = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQuery(QueryBuilder query, QueryBuilder filter) {
|
public NativeSearchQuery(QueryBuilder query, QueryBuilder filter) {
|
||||||
this.query = query;
|
this.query = query;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQuery(QueryBuilder query, QueryBuilder filter, List<SortBuilder> sorts) {
|
public NativeSearchQuery(QueryBuilder query, QueryBuilder filter, List<SortBuilder> sorts) {
|
||||||
this.query = query;
|
this.query = query;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.sorts = sorts;
|
this.sorts = sorts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQuery(QueryBuilder query, QueryBuilder filter, List<SortBuilder> sorts, HighlightBuilder.Field[] highlightFields) {
|
public NativeSearchQuery(QueryBuilder query, QueryBuilder filter, List<SortBuilder> sorts, HighlightBuilder.Field[] highlightFields) {
|
||||||
this.query = query;
|
this.query = query;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.sorts = sorts;
|
this.sorts = sorts;
|
||||||
this.highlightFields = highlightFields;
|
this.highlightFields = highlightFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryBuilder getQuery() {
|
public QueryBuilder getQuery() {
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryBuilder getFilter() {
|
public QueryBuilder getFilter() {
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SortBuilder> getElasticsearchSorts() {
|
public List<SortBuilder> getElasticsearchSorts() {
|
||||||
return sorts;
|
return sorts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HighlightBuilder.Field[] getHighlightFields() {
|
public HighlightBuilder.Field[] getHighlightFields() {
|
||||||
return highlightFields;
|
return highlightFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ScriptField> getScriptFields() { return scriptFields; }
|
public List<ScriptField> getScriptFields() { return scriptFields; }
|
||||||
|
|
||||||
public void setScriptFields(List<ScriptField> scriptFields) {
|
public void setScriptFields(List<ScriptField> scriptFields) {
|
||||||
this.scriptFields.addAll(scriptFields);
|
this.scriptFields.addAll(scriptFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addScriptField(ScriptField... scriptField) {
|
public void addScriptField(ScriptField... scriptField) {
|
||||||
scriptFields.addAll(Arrays.asList(scriptField));
|
scriptFields.addAll(Arrays.asList(scriptField));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFacet(FacetRequest facetRequest) {
|
public void addFacet(FacetRequest facetRequest) {
|
||||||
if (facets == null) {
|
if (facets == null) {
|
||||||
facets = new ArrayList<FacetRequest>();
|
facets = new ArrayList<FacetRequest>();
|
||||||
}
|
}
|
||||||
facets.add(facetRequest);
|
facets.add(facetRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFacets(List<FacetRequest> facets) {
|
public void setFacets(List<FacetRequest> facets) {
|
||||||
this.facets = facets;
|
this.facets = facets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FacetRequest> getFacets() {
|
public List<FacetRequest> getFacets() {
|
||||||
return facets;
|
return facets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AbstractAggregationBuilder> getAggregations() {
|
public List<AbstractAggregationBuilder> getAggregations() {
|
||||||
return aggregations;
|
return aggregations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addAggregation(AbstractAggregationBuilder aggregationBuilder) {
|
public void addAggregation(AbstractAggregationBuilder aggregationBuilder) {
|
||||||
if (aggregations == null) {
|
if (aggregations == null) {
|
||||||
aggregations = new ArrayList<AbstractAggregationBuilder>();
|
aggregations = new ArrayList<AbstractAggregationBuilder>();
|
||||||
}
|
}
|
||||||
aggregations.add(aggregationBuilder);
|
aggregations.add(aggregationBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggregations(List<AbstractAggregationBuilder> aggregations) {
|
public void setAggregations(List<AbstractAggregationBuilder> aggregations) {
|
||||||
this.aggregations = aggregations;
|
this.aggregations = aggregations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IndexBoost> getIndicesBoost() {
|
public List<IndexBoost> getIndicesBoost() {
|
||||||
return indicesBoost;
|
return indicesBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndicesBoost(List<IndexBoost> indicesBoost) {
|
public void setIndicesBoost(List<IndexBoost> indicesBoost) {
|
||||||
this.indicesBoost = indicesBoost;
|
this.indicesBoost = indicesBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+199
-199
@@ -1,199 +1,199 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import static org.springframework.util.CollectionUtils.isEmpty;
|
import static org.springframework.util.CollectionUtils.isEmpty;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.elasticsearch.action.search.SearchType;
|
import org.elasticsearch.action.search.SearchType;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
||||||
import org.elasticsearch.search.highlight.HighlightBuilder;
|
import org.elasticsearch.search.highlight.HighlightBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilder;
|
import org.elasticsearch.search.sort.SortBuilder;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeSearchQuery
|
* NativeSearchQuery
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class NativeSearchQueryBuilder {
|
public class NativeSearchQueryBuilder {
|
||||||
|
|
||||||
private QueryBuilder queryBuilder;
|
private QueryBuilder queryBuilder;
|
||||||
private QueryBuilder filterBuilder;
|
private QueryBuilder filterBuilder;
|
||||||
private List<ScriptField> scriptFields = new ArrayList<ScriptField>();
|
private List<ScriptField> scriptFields = new ArrayList<ScriptField>();
|
||||||
private List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>();
|
private List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>();
|
||||||
private List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
|
private List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
|
||||||
private List<AbstractAggregationBuilder> aggregationBuilders = new ArrayList<AbstractAggregationBuilder>();
|
private List<AbstractAggregationBuilder> aggregationBuilders = new ArrayList<AbstractAggregationBuilder>();
|
||||||
private HighlightBuilder.Field[] highlightFields;
|
private HighlightBuilder.Field[] highlightFields;
|
||||||
private Pageable pageable;
|
private Pageable pageable;
|
||||||
private String[] indices;
|
private String[] indices;
|
||||||
private String[] types;
|
private String[] types;
|
||||||
private String[] fields;
|
private String[] fields;
|
||||||
private SourceFilter sourceFilter;
|
private SourceFilter sourceFilter;
|
||||||
private List<IndexBoost> indicesBoost;
|
private List<IndexBoost> indicesBoost;
|
||||||
private float minScore;
|
private float minScore;
|
||||||
private Collection<String> ids;
|
private Collection<String> ids;
|
||||||
private String route;
|
private String route;
|
||||||
private SearchType searchType;
|
private SearchType searchType;
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withQuery(QueryBuilder queryBuilder) {
|
public NativeSearchQueryBuilder withQuery(QueryBuilder queryBuilder) {
|
||||||
this.queryBuilder = queryBuilder;
|
this.queryBuilder = queryBuilder;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withFilter(QueryBuilder filterBuilder) {
|
public NativeSearchQueryBuilder withFilter(QueryBuilder filterBuilder) {
|
||||||
this.filterBuilder = filterBuilder;
|
this.filterBuilder = filterBuilder;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withSort(SortBuilder sortBuilder) {
|
public NativeSearchQueryBuilder withSort(SortBuilder sortBuilder) {
|
||||||
this.sortBuilders.add(sortBuilder);
|
this.sortBuilders.add(sortBuilder);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withScriptField(ScriptField scriptField) {
|
public NativeSearchQueryBuilder withScriptField(ScriptField scriptField) {
|
||||||
this.scriptFields.add(scriptField);
|
this.scriptFields.add(scriptField);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder addAggregation(AbstractAggregationBuilder aggregationBuilder) {
|
public NativeSearchQueryBuilder addAggregation(AbstractAggregationBuilder aggregationBuilder) {
|
||||||
this.aggregationBuilders.add(aggregationBuilder);
|
this.aggregationBuilders.add(aggregationBuilder);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withFacet(FacetRequest facetRequest) {
|
public NativeSearchQueryBuilder withFacet(FacetRequest facetRequest) {
|
||||||
facetRequests.add(facetRequest);
|
facetRequests.add(facetRequest);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withHighlightFields(HighlightBuilder.Field... highlightFields) {
|
public NativeSearchQueryBuilder withHighlightFields(HighlightBuilder.Field... highlightFields) {
|
||||||
this.highlightFields = highlightFields;
|
this.highlightFields = highlightFields;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withIndicesBoost(List<IndexBoost> indicesBoost) {
|
public NativeSearchQueryBuilder withIndicesBoost(List<IndexBoost> indicesBoost) {
|
||||||
this.indicesBoost = indicesBoost;
|
this.indicesBoost = indicesBoost;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withPageable(Pageable pageable) {
|
public NativeSearchQueryBuilder withPageable(Pageable pageable) {
|
||||||
this.pageable = pageable;
|
this.pageable = pageable;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withIndices(String... indices) {
|
public NativeSearchQueryBuilder withIndices(String... indices) {
|
||||||
this.indices = indices;
|
this.indices = indices;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withTypes(String... types) {
|
public NativeSearchQueryBuilder withTypes(String... types) {
|
||||||
this.types = types;
|
this.types = types;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withFields(String... fields) {
|
public NativeSearchQueryBuilder withFields(String... fields) {
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withSourceFilter(SourceFilter sourceFilter) {
|
public NativeSearchQueryBuilder withSourceFilter(SourceFilter sourceFilter) {
|
||||||
this.sourceFilter = sourceFilter;
|
this.sourceFilter = sourceFilter;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withMinScore(float minScore) {
|
public NativeSearchQueryBuilder withMinScore(float minScore) {
|
||||||
this.minScore = minScore;
|
this.minScore = minScore;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withIds(Collection<String> ids) {
|
public NativeSearchQueryBuilder withIds(Collection<String> ids) {
|
||||||
this.ids = ids;
|
this.ids = ids;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withRoute(String route) {
|
public NativeSearchQueryBuilder withRoute(String route) {
|
||||||
this.route = route;
|
this.route = route;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withSearchType(SearchType searchType) {
|
public NativeSearchQueryBuilder withSearchType(SearchType searchType) {
|
||||||
this.searchType = searchType;
|
this.searchType = searchType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQuery build() {
|
public NativeSearchQuery build() {
|
||||||
NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(queryBuilder, filterBuilder, sortBuilders, highlightFields);
|
NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(queryBuilder, filterBuilder, sortBuilders, highlightFields);
|
||||||
if (pageable != null) {
|
if (pageable != null) {
|
||||||
nativeSearchQuery.setPageable(pageable);
|
nativeSearchQuery.setPageable(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indices != null) {
|
if (indices != null) {
|
||||||
nativeSearchQuery.addIndices(indices);
|
nativeSearchQuery.addIndices(indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (types != null) {
|
if (types != null) {
|
||||||
nativeSearchQuery.addTypes(types);
|
nativeSearchQuery.addTypes(types);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields != null) {
|
if (fields != null) {
|
||||||
nativeSearchQuery.addFields(fields);
|
nativeSearchQuery.addFields(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceFilter != null) {
|
if (sourceFilter != null) {
|
||||||
nativeSearchQuery.addSourceFilter(sourceFilter);
|
nativeSearchQuery.addSourceFilter(sourceFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(indicesBoost != null) {
|
if(indicesBoost != null) {
|
||||||
nativeSearchQuery.setIndicesBoost(indicesBoost);
|
nativeSearchQuery.setIndicesBoost(indicesBoost);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmpty(scriptFields)) {
|
if (!isEmpty(scriptFields)) {
|
||||||
nativeSearchQuery.setScriptFields(scriptFields);
|
nativeSearchQuery.setScriptFields(scriptFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmpty(facetRequests)) {
|
if (!isEmpty(facetRequests)) {
|
||||||
nativeSearchQuery.setFacets(facetRequests);
|
nativeSearchQuery.setFacets(facetRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmpty(aggregationBuilders)) {
|
if (!isEmpty(aggregationBuilders)) {
|
||||||
nativeSearchQuery.setAggregations(aggregationBuilders);
|
nativeSearchQuery.setAggregations(aggregationBuilders);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minScore > 0) {
|
if (minScore > 0) {
|
||||||
nativeSearchQuery.setMinScore(minScore);
|
nativeSearchQuery.setMinScore(minScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ids != null) {
|
if (ids != null) {
|
||||||
nativeSearchQuery.setIds(ids);
|
nativeSearchQuery.setIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route != null) {
|
if (route != null) {
|
||||||
nativeSearchQuery.setRoute(route);
|
nativeSearchQuery.setRoute(route);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchType != null) {
|
if (searchType != null) {
|
||||||
nativeSearchQuery.setSearchType(searchType);
|
nativeSearchQuery.setSearchType(searchType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nativeSearchQuery;
|
return nativeSearchQuery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,157 +1,157 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.action.search.SearchType;
|
import org.elasticsearch.action.search.SearchType;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query
|
* Query
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public interface Query {
|
public interface Query {
|
||||||
|
|
||||||
public static final int DEFAULT_PAGE_SIZE = 10;
|
public static final int DEFAULT_PAGE_SIZE = 10;
|
||||||
public static final Pageable DEFAULT_PAGE = new PageRequest(0, DEFAULT_PAGE_SIZE);
|
public static final Pageable DEFAULT_PAGE = new PageRequest(0, DEFAULT_PAGE_SIZE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restrict result to entries on given page. Corresponds to the 'start' and 'rows' parameter in elasticsearch
|
* restrict result to entries on given page. Corresponds to the 'start' and 'rows' parameter in elasticsearch
|
||||||
*
|
*
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
<T extends Query> T setPageable(Pageable pageable);
|
<T extends Query> T setPageable(Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get filter queries if defined
|
* Get filter queries if defined
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// List<FilterQuery> getFilterQueries();
|
// List<FilterQuery> getFilterQueries();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get page settings if defined
|
* Get page settings if defined
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Pageable getPageable();
|
Pageable getPageable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add {@link org.springframework.data.domain.Sort} to query
|
* Add {@link org.springframework.data.domain.Sort} to query
|
||||||
*
|
*
|
||||||
* @param sort
|
* @param sort
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
<T extends Query> T addSort(Sort sort);
|
<T extends Query> T addSort(Sort sort);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null if not set
|
* @return null if not set
|
||||||
*/
|
*/
|
||||||
Sort getSort();
|
Sort getSort();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Indices to be searched
|
* Get Indices to be searched
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<String> getIndices();
|
List<String> getIndices();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Indices to be added as part of search request
|
* Add Indices to be added as part of search request
|
||||||
*
|
*
|
||||||
* @param indices
|
* @param indices
|
||||||
*/
|
*/
|
||||||
void addIndices(String... indices);
|
void addIndices(String... indices);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add types to be searched
|
* Add types to be searched
|
||||||
*
|
*
|
||||||
* @param types
|
* @param types
|
||||||
*/
|
*/
|
||||||
void addTypes(String... types);
|
void addTypes(String... types);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get types to be searched
|
* Get types to be searched
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<String> getTypes();
|
List<String> getTypes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add fields to be added as part of search request
|
* Add fields to be added as part of search request
|
||||||
*
|
*
|
||||||
* @param fields
|
* @param fields
|
||||||
*/
|
*/
|
||||||
void addFields(String... fields);
|
void addFields(String... fields);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get fields to be returned as part of search request
|
* Get fields to be returned as part of search request
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<String> getFields();
|
List<String> getFields();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add source filter to be added as part of search request
|
* Add source filter to be added as part of search request
|
||||||
*
|
*
|
||||||
* @param sourceFilter
|
* @param sourceFilter
|
||||||
*/
|
*/
|
||||||
void addSourceFilter(SourceFilter sourceFilter);
|
void addSourceFilter(SourceFilter sourceFilter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get SourceFilter to be returned to get include and exclude source
|
* Get SourceFilter to be returned to get include and exclude source
|
||||||
* fields as part of search request.
|
* fields as part of search request.
|
||||||
*
|
*
|
||||||
* @return SourceFilter
|
* @return SourceFilter
|
||||||
*/
|
*/
|
||||||
SourceFilter getSourceFilter();
|
SourceFilter getSourceFilter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get minimum score
|
* Get minimum score
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
float getMinScore();
|
float getMinScore();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Ids
|
* Get Ids
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Collection<String> getIds();
|
Collection<String> getIds();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get route
|
* Get route
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getRoute();
|
String getRoute();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of search
|
* Type of search
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
SearchType getSearchType();
|
SearchType getSearchType();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +1,52 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
||||||
import org.elasticsearch.search.highlight.HighlightBuilder;
|
import org.elasticsearch.search.highlight.HighlightBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilder;
|
import org.elasticsearch.search.sort.SortBuilder;
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeSearchQuery
|
* NativeSearchQuery
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
public interface SearchQuery extends Query {
|
public interface SearchQuery extends Query {
|
||||||
|
|
||||||
QueryBuilder getQuery();
|
QueryBuilder getQuery();
|
||||||
|
|
||||||
QueryBuilder getFilter();
|
QueryBuilder getFilter();
|
||||||
|
|
||||||
List<SortBuilder> getElasticsearchSorts();
|
List<SortBuilder> getElasticsearchSorts();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
List<FacetRequest> getFacets();
|
List<FacetRequest> getFacets();
|
||||||
|
|
||||||
List<AbstractAggregationBuilder> getAggregations();
|
List<AbstractAggregationBuilder> getAggregations();
|
||||||
|
|
||||||
HighlightBuilder.Field[] getHighlightFields();
|
HighlightBuilder.Field[] getHighlightFields();
|
||||||
|
|
||||||
List<IndexBoost> getIndicesBoost();
|
List<IndexBoost> getIndicesBoost();
|
||||||
|
|
||||||
List<ScriptField> getScriptFields();
|
List<ScriptField> getScriptFields();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +1,41 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The most trivial implementation of a Field
|
* The most trivial implementation of a Field
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class SimpleField implements Field {
|
public class SimpleField implements Field {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
public SimpleField(String name) {
|
public SimpleField(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 the original author or authors.
|
* Copyright 2016-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -1,49 +1,49 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StringQuery
|
* StringQuery
|
||||||
*
|
*
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class StringQuery extends AbstractQuery {
|
public class StringQuery extends AbstractQuery {
|
||||||
|
|
||||||
private String source;
|
private String source;
|
||||||
|
|
||||||
public StringQuery(String source) {
|
public StringQuery(String source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringQuery(String source, Pageable pageable) {
|
public StringQuery(String source, Pageable pageable) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.pageable = pageable;
|
this.pageable = pageable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringQuery(String source, Pageable pageable, Sort sort) {
|
public StringQuery(String source, Pageable pageable, Sort sort) {
|
||||||
this.pageable = pageable;
|
this.pageable = pageable;
|
||||||
this.sort = sort;
|
this.sort = sort;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSource() {
|
public String getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user