Skip to content

How to start with spring data elasticsearch

stephlag edited this page Jul 3, 2014 · 9 revisions

First you will need to ask yourself how you will use this framework.

Case 1:

I need only index and search documents in my project.

How to configure your project:

First add to your pom.xml file information about snapshot repository for spring-data-elasticsearch

<repositories>
...
    <repository>
        <id>spring-snapshot</id>
        <name>Spring Maven SNAPSHOT Repository</name>
        <url>http://repo.springsource.org/libs-snapshot</url>
    </repository>
...
<repositories>

Second add dependency for spring-data-elasticsearch

<dependencies>
...
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>1.0.0.BUILD-SNAPSHOT</version>
    </dependency> 
...
</dependencies>

Having both entries in the pom file you should be able to use spring-data-elasticsearch without any issues.

Case 2:

I have a plan to develop new feature / or extend existing ones.

How to configure your project:

Project has dependencies with spring-data-parent to fulfill that we need to add information about snapshot spring repository and snapshot spring plugin repository.

Snapshot spring repository:

<repository>
    <id>spring-snapshot</id>
    <name>Spring Maven SNAPSHOT Repository</name>
    <url>http://repo.springsource.org/libs-snapshot</url>
</repository>

Snapshot spring plugin repository:

<pluginRepository>
    <id>com.springsource.repository.bundles.release</id>
    <url>http://repository.springsource.com/maven/bundles/release</url>
</pluginRepository>

The best way to do that without polluting spring-data-elasticsearch pom.xml is create / edit 'settings.xml' file in your '.m2' folder.

Example of the file can be found here