Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeBuilder not found in the ElasticSearch API application

I am trying to implement the Elasticsearch API. I have errors with the system accepting nodeBuilder. Here is the code -

import org.elasticsearch.action.index.IndexResponse;   
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.Client;
//import org.elasticsearch.common.settings.ImmutableSettings; 
import org.elasticsearch.common.settings.*;
import org.elasticsearch.ElasticsearchException; 
import org.elasticsearch.action.search.SearchResponse; 
import org.elasticsearch.action.search.SearchType; 
import org.elasticsearch.client.transport.TransportClient; 
import   org.elasticsearch.node.NodeBuilder.*;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress; 
import org.elasticsearch.common.unit.TimeValue; 
import org.elasticsearch.index.query.QueryBuilders; 
import org.elasticsearch.search.SearchHit; 



    // on startup

    Node node = nodeBuilder().node(); // nodeBuilder not recognised.
    Client client = node.client();

    // on shutdown

    node.close();


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

Client is recognised. Any ideas?

like image 864
Trevor Oakley Avatar asked Feb 11 '16 14:02

Trevor Oakley


1 Answers

ClientBuilder is removed in ES API 5.

You can use org.elasticsearch.common.settings.Settings.builder() which will give you an instance of Builder.

Exp :

Settings.Builder elasticsearchSettings =
                Settings.builder()
                        .put("http.enabled", "true") 
                        .put("index.number_of_shards", "1")
                        .put("path.data", new File(tmpDir, "data").getAbsolutePath()) 
                        .put("path.logs", new File(tmpDir, "logs").getAbsolutePath()) 
                        .put("path.work", new File(tmpDir, "work").getAbsolutePath()) 
                        .put("path.home", tmpDir); 
like image 103
Mehraj Malik Avatar answered Oct 03 '22 09:10

Mehraj Malik