Maven dependencies with elasticsearch

i'm new with elasticsearch and i'm trying to make a java application that will allow me to communicate with a cluster elasticsearch . i started with creating a maven project and in the pom.xml i have put in my pom.xml the code bellow:

<dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>2.3.3</version> </dependency>

in the main class i have put

> import org.elasticsearch.client.Client;
> import org.elasticsearch.client.transport.TransportClient;
> import org.elasticsearch.common.transport.InetSocketTransportAddress;
> import org.elasticsearch.index.query.SimpleQueryParser.Settings;
> import org.springframework.context.annotation.Bean;
> import org.springframework.context.annotation.Configuration;
> import org.springframework.context.annotation.PropertySource;
> import org.springframework.core.env.Environment;
> import;
> import;
> import;

> import javax.annotation.Resource;

> @Configuration
> @PropertySource(value = "")
> @EnableElasticsearchRepositories(basePackages = "com.biganalytics.project.repositories")
> public class ElasticsearchConfiguration {
>     @Resource
>     private Environment environment;
>     @Bean
>     public Client client() {
>     	Client client = new TransportClient()
>         		 TransportAddress address = new InetSocketTransportAddress(environment.getProperty(""), Integer.parseInt(environment.getProperty("elasticsearch.port")));
>         client.addTransportAddress(address);
>     }
>     @Bean
>    public ElasticsearchOperations elasticsearchTemplate() {
>         return new ElasticsearchTemplate(client());
> }
> }

but this class didn't work and i have errors :The constructor InetSocketTransportAddress(String, int) is undefined and The method addTransportAddress(TransportAddress) is undefined for the type Client

can anyone tell me what is the problem
thanks a lot

May be you are mixing some versions of elasticsearch in your project?
Sounds like you are using Spring, right? May be run a mvn dependency:tree would help?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.