Specifying default replicas and shards for an index

Hi guys,

Initially if you just start an elastic search server and try to create
an index you will get 5 shards and 2 replicas (I hope I am not wrong).
How can I configure this? I know that I can send a JSON / Text
initially when I am creating a new index but I don't want every time
when a new index is created to specify the shards/replicas I want
initially to use different values than 5 shards and 2 replicas.

Thank you.

{
"cluster":{
"name":"elasticsearch"
},
"gateway":{
"recover_after_nodes": 1,
"recover_after_time": "5m",
"expected_nodes": 2
},
"index" : {
"number_of_shards":3,
"number_of_replicas":2,
}
}

On Jun 1, 3:17 pm, paranoiabla paranoia...@gmail.com wrote:

Hi guys,

Initially if you just start an Elasticsearch server and try to create
an index you will get 5 shards and 2 replicas (I hope I am not wrong).
How can I configure this? I know that I can send a JSON / Text
initially when I am creating a new index but I don't want every time
when a new index is created to specify the shards/replicas I want
initially to use different values than 5 shards and 2 replicas.

Thank you.

Ok,

I saw that there is a config folder when you download the standalone
Elasticsearch. And inside this config folder there is a file :
elasticsearch.yml where I can specify these values. This all is great
BUT in my case I am using a standalone server started from a Java
class, like below:

======
public static void main(String args) {
System.out.println("Starting Elastic Search Server");

	Builder settings = ImmutableSettings.settingsBuilder();
	// here you can set the node and index settings via API
	settings.build();

	NodeBuilder nBuilder = nodeBuilder().settings(settings);
	nBuilder.local(true);

	// start it!
	Node node = nBuilder.build().start();

	System.out.println("Started Elastic Search Server");

=====

How can I pass these configuration options, when using the Java API
directly?

Thanks.

On Jun 1, 11:07 am, Weiwei Wang ww.wang...@gmail.com wrote:

{
"cluster":{
"name":"elasticsearch"
},
"gateway":{
"recover_after_nodes": 1,
"recover_after_time": "5m",
"expected_nodes": 2
},
"index" : {
"number_of_shards":3,
"number_of_replicas":2,
}

}

On Jun 1, 3:17 pm, paranoiabla paranoia...@gmail.com wrote:

Hi guys,

Initially if you just start an Elasticsearch server and try to create
an index you will get 5 shards and 2 replicas (I hope I am not wrong).
How can I configure this? I know that I can send a JSON / Text
initially when I am creating a new index but I don't want every time
when a new index is created to specify the shards/replicas I want
initially to use different values than 5 shards and 2 replicas.

Thank you.

Put in the the settings for the node.

On Wednesday, June 1, 2011 at 11:27 AM, paranoiabla wrote:

Ok,

I saw that there is a config folder when you download the standalone
Elasticsearch. And inside this config folder there is a file :
elasticsearch.yml where I can specify these values. This all is great
BUT in my case I am using a standalone server started from a Java
class, like below:

======
public static void main(String args) {
System.out.println("Starting Elastic Search Server");

Builder settings = ImmutableSettings.settingsBuilder();
// here you can set the node and index settings via API
settings.build();

NodeBuilder nBuilder = nodeBuilder().settings(settings);
nBuilder.local(true);

// start it!
Node node = nBuilder.build().start();

System.out.println("Started Elastic Search Server");

How can I pass these configuration options, when using the Java API
directly?

Thanks.

On Jun 1, 11:07 am, Weiwei Wang <ww.wang...@gmail.com (http://gmail.com)> wrote:

{
"cluster":{
"name":"elasticsearch"
},
"gateway":{
"recover_after_nodes": 1,
"recover_after_time": "5m",
"expected_nodes": 2
},
"index" : {
"number_of_shards":3,
"number_of_replicas":2,
}

}

On Jun 1, 3:17 pm, paranoiabla <paranoia...@gmail.com (http://gmail.com)> wrote:

Hi guys,

Initially if you just start an Elasticsearch server and try to create
an index you will get 5 shards and 2 replicas (I hope I am not wrong).
How can I configure this? I know that I can send a JSON / Text
initially when I am creating a new index but I don't want every time
when a new index is created to specify the shards/replicas I want
initially to use different values than 5 shards and 2 replicas.

Thank you.

Hi Shay,

From node.settings() I can only read the settings values but I cannot
change them - there are only getter methods. Can you show a snippet -
maybe I don't understanding correctly.

Cheers, Petar.

On Jun 1, 1:56 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Put in the the settings for the node.

On Wednesday, June 1, 2011 at 11:27 AM, paranoiabla wrote:

Ok,

I saw that there is a config folder when you download the standalone
Elasticsearch. And inside this config folder there is a file :
elasticsearch.yml where I can specify these values. This all is great
BUT in my case I am using a standalone server started from a Java
class, like below:

======
public static void main(String args) {
System.out.println("Starting Elastic Search Server");

Builder settings = ImmutableSettings.settingsBuilder();
// here you can set the node and index settings via API
settings.build();

NodeBuilder nBuilder = nodeBuilder().settings(settings);
nBuilder.local(true);

// start it!
Node node = nBuilder.build().start();

System.out.println("Started Elastic Search Server");

How can I pass these configuration options, when using the Java API
directly?

Thanks.

On Jun 1, 11:07 am, Weiwei Wang <ww.wang...@gmail.com (http://gmail.com)> wrote:

{
"cluster":{
"name":"elasticsearch"
},
"gateway":{
"recover_after_nodes": 1,
"recover_after_time": "5m",
"expected_nodes": 2
},
"index" : {
"number_of_shards":3,
"number_of_replicas":2,
}

}

On Jun 1, 3:17 pm, paranoiabla <paranoia...@gmail.com (http://gmail.com)> wrote:

Hi guys,

Initially if you just start an Elasticsearch server and try to create
an index you will get 5 shards and 2 replicas (I hope I am not wrong).
How can I configure this? I know that I can send a JSON / Text
initially when I am creating a new index but I don't want every time
when a new index is created to specify the shards/replicas I want
initially to use different values than 5 shards and 2 replicas.

Thank you.

Its already in your code (the comment you have), I added a sample:

Builder settings = ImmutableSettings.settingsBuilder();
// here you can set the node and index settings via API
settings.put("index.number_of_shards", 1);
settings.build();

NodeBuilder nBuilder = nodeBuilder().settings(settings);

On Wednesday, June 1, 2011 at 4:56 PM, paranoiabla wrote:

Hi Shay,

From node.settings() I can only read the settings values but I cannot
change them - there are only getter methods. Can you show a snippet -
maybe I don't understanding correctly.

Cheers, Petar.

On Jun 1, 1:56 pm, Shay Banon <shay.ba...@elasticsearch.com (http://elasticsearch.com)> wrote:

Put in the the settings for the node.

On Wednesday, June 1, 2011 at 11:27 AM, paranoiabla wrote:

Ok,

I saw that there is a config folder when you download the standalone
Elasticsearch. And inside this config folder there is a file :
elasticsearch.yml where I can specify these values. This all is great
BUT in my case I am using a standalone server started from a Java
class, like below:

======
public static void main(String args) {
System.out.println("Starting Elastic Search Server");

Builder settings = ImmutableSettings.settingsBuilder();
// here you can set the node and index settings via API
settings.build();

NodeBuilder nBuilder = nodeBuilder().settings(settings);
nBuilder.local(true);

// start it!
Node node = nBuilder.build().start();

System.out.println("Started Elastic Search Server");

How can I pass these configuration options, when using the Java API
directly?

Thanks.

On Jun 1, 11:07 am, Weiwei Wang <ww.wang...@gmail.com (http://gmail.com)> wrote:

{
"cluster":{
"name":"elasticsearch"
},
"gateway":{
"recover_after_nodes": 1,
"recover_after_time": "5m",
"expected_nodes": 2
},
"index" : {
"number_of_shards":3,
"number_of_replicas":2,
}

}

On Jun 1, 3:17 pm, paranoiabla <paranoia...@gmail.com (http://gmail.com)> wrote:

Hi guys,

Initially if you just start an Elasticsearch server and try to create
an index you will get 5 shards and 2 replicas (I hope I am not wrong).
How can I configure this? I know that I can send a JSON / Text
initially when I am creating a new index but I don't want every time
when a new index is created to specify the shards/replicas I want
initially to use different values than 5 shards and 2 replicas.

Thank you.