hello,
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 org.springframework.data.elasticsearch.core.ElasticsearchOperations;
> import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
> import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
> import javax.annotation.Resource;
> @Configuration
> @PropertySource(value = "classpath:elasticsearch.properties")
> @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("elasticsearch.host"), 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