Skip to content

How to start with spring data elasticsearch

akonczak edited this page Aug 27, 2013 · 9 revisions

First you will need to answer to 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 plane to develop new feature / or extend existing ones.

How to configure your project:

Project has dependencies with spring-data-parent to fulfil 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 https://github.com/akonczak/spring-data-elasticsearch-mvn-config/blob/master/settings.xml