Java API Client And Node


(samCougars) #1

I'm using JAVA API.
When I'm indexing document, I create a node by setting properties and close it as follow:
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
settings.put("path.home","elasticSearchNode");
settings.put("number_of_shards",1);
settings.put("number_of_replicas",0);

Node node = NodeBuilder.nodeBuilder().settings(settings).clusterName(elasticSearchNode).node();
node .close();

But when I'm doing search, I get the node as follows :
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
settings.put("path.home","elasticSearchNode");
Node node = NodeBuilder.nodeBuilder().settings(settings).clusterName(elasticSearchNode).node();

But, I'm not closing this node because when a next search request comes to, it uses the same node.

Is it bad to leave the node open for next request? What are the downsides of my approach?
Thanks


(Eric Jain) #2

On Jun 13, 9:55 am, samCougars sban...@gmail.com wrote:

Is it bad to leave the node open for next request? What are the downsides of
my approach?

Nodes (and Clients) are expensive to create, and I'm not aware of any
reasons to create more than one instance each per application.


(system) #3