简体   繁体   中英

Combine springBoot with elasticsearch 2.x

I try to use spring boot 1.3.3 to realise project that communicate with elasticsearch. After many searches in the net, I found that spring-boot-starter-data-elasticsearch is not good in my case because it's using Elasticsearch 1.5 and i have to use Elasticsearch 2.2 There is still a hope to use spring boot ?

Of course you can use Spring Boot with Elasticsearch 2.x. I am using it. Here is an extract of my gradle.build.

apply plugin: 'spring-boot'

buildscript {
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
    }
}

dependencies {
    // Elasticsearch
    compile ("org.elasticsearch:elasticsearch:2.1.1")

    // Spring Boot
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("org.springframework.boot:spring-boot-starter-web")
    ...
}
...

Just do not use spring-boot-starter-data-elasticsearch if it does not suit your needs.

You can come back and update your dependencies if you need to, once the spring-boot-starter is updated with the latest version. There is currently a 2.0.0.RC1 version of spring-data-elasticsearch for version 2.2.0 of Elasticsearch, so it is reasonable to assume that the spring-boot-starter will be updated soon as well.

Hope this helps.

Only spring-data-elasticsearch subproject is tied to Elasticsearch. And btw, IMHO this integration really sucks, because they tried to fit very flexible Elasticsearch API to quite limited interfaces. If you want to use Spring Boot for microservices infrastructure and other stuff, just use it with appropriate version of elasticsearch client, don't bother with spring-boot-starter-data-elasticsearch.

We use https://github.com/searchbox-io/Jest succesfully with Spring Boot. Formerly we tried to use spring-data-elasticsearch but it didn't work nice for us together with sping-data-mongodb. Then we moved to JEST and never looked back.

Simply add

compile('io.searchbox:jest:2.0.2')

to gradle config file. JEST has a huge set of tests where you can find all possible use cases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM