Add Jest support

This commit adds auto-configuration support for Jest, an HTTP client for
Elasticsearch. If Jest is present, a `JestClient` targeting a local
elasticsearch instance is auto-configured. Several properties from the
`spring.jest.*` namespace allows to tune the client.

Closes gh-6032
This commit is contained in:
Stephane Nicoll
2016-06-13 11:12:49 +02:00
parent 50ca35bdae
commit 7afe1d16a6
8 changed files with 322 additions and 2 deletions

View File

@@ -629,6 +629,13 @@ content into your application; rather pick only the properties that you need.
spring.h2.console.settings.trace=false # Enable trace output.
spring.h2.console.settings.web-allow-others=false # Enable remote access.
# JEST (ElasticSearch HTTP client) ({sc-spring-boot-autoconfigure}/jest/JestProperties.{sc-ext}[JestProperties])
spring.jest.connection-timeout=3000 # Connection timeout in milliseconds.
spring.jest.password= # Login password.
spring.jest.read-timeout=3000 # Read timeout in milliseconds.
spring.jest.uris=http://localhost:9200 # Comma-separated list of the elasticsearch instances to use.
spring.jest.username= # Login user.
# JOOQ ({sc-spring-boot-autoconfigure}/jooq/JooqAutoConfiguration.{sc-ext}[JooqAutoConfiguration])
spring.jooq.sql-dialect= # SQLDialect JOOQ used when communicating with the configured datasource. For instance `POSTGRES`

View File

@@ -3315,12 +3315,31 @@ real-time search and analytics engine. Spring Boot offers basic auto-configurati
the Elasticsearch and abstractions on top of it provided by
https://github.com/spring-projects/spring-data-elasticsearch[Spring Data Elasticsearch].
There is a `spring-boot-starter-data-elasticsearch` '`Starter`' for collecting the
dependencies in a convenient way.
dependencies in a convenient way. Spring Boot also supports
https://github.com/searchbox-io/Jest[Jest].
[[boot-features-connecting-to-elasticsearch-jest]]
==== Connecting to Elasticsearch using Spring Data
If you have `Jest` on the classpath, you can inject an auto-configured `JestClient`
targeting `http://localhost:9200` by default. You can further tune how the client is
configured:
[source,properties,indent=0]
----
spring.jest.uris=http://search.example.com:9200
spring.jest.read-timeout=10000
spring.jest.username=user
spring.jest.password=secret
----
To take full control over the registration, define a `JestClient` bean.
[[boot-features-connecting-to-elasticsearch]]
==== Connecting to Elasticsearch
[[boot-features-connecting-to-elasticsearch-spring-data]]
==== Connecting to Elasticsearch using Spring Data
You can inject an auto-configured `ElasticsearchTemplate` or Elasticsearch `Client`
instance as you would any other Spring Bean. By default the instance will embed a
local in-memory server (a `Node` in ElasticSearch terms) and use the current working