Hi all,
Like all ES newbies, I also get UnavailableShardsException when using the
Java API. I have a 3-node cluster, 2 data + the Java non-data client. The 2
ES nodes have replicas and shards # configured in yml, but unfortunately I
can't seem to find where to configure these settings in the Java Client API
for the non-data node embedded in my app?
I tried bypassing this using index templates, but these settings don't seem
to be honored. My code below.
final String GeneralTemplate = "{\n" +
" \"template\" : \"el-*\",\n" +
" \"settings\" : {\n" +
" \"number_of_shards\" : 1,\n" +
" \"number_of_replicas\" : 0 \n" +
" },\n" +
" \"mappings\" : {\n" +
" \"foo\" : {\n" +
// ...
" }\n" + " }\n" +
" }\n" +
"}";
node.client().admin().indices().preparePutTemplate("general")
.setSource(GeneralTemplate).execute().actionGet(); //
executed after waiting for green status
My last resort is to manually create indexes with a index-exists check
beforehand, and providing those settings per index. I can verify this
works, but I'd really like to avoid that.
Thanks in advance.
Itamar.
--
Found my issue - somehow the cluster was with a red status
(unassigned_shards == 51 or so) and the call to setWaitForGreenStatus went
through without throwing any error.
Not sure how it got to that state or why the ES didn't error. After
starting over with a fresh cluster everything is working properly.
On Wed, Oct 3, 2012 at 10:37 AM, Itamar Syn-Hershko itamar@code972.comwrote:
Hi all,
Like all ES newbies, I also get UnavailableShardsException when using the
Java API. I have a 3-node cluster, 2 data + the Java non-data client. The 2
ES nodes have replicas and shards # configured in yml, but unfortunately I
can't seem to find where to configure these settings in the Java Client API
for the non-data node embedded in my app?
I tried bypassing this using index templates, but these settings don't
seem to be honored. My code below.
final String GeneralTemplate = "{\n" +
" \"template\" : \"el-*\",\n" +
" \"settings\" : {\n" +
" \"number_of_shards\" : 1,\n" +
" \"number_of_replicas\" : 0 \n" +
" },\n" +
" \"mappings\" : {\n" +
" \"foo\" : {\n" +
// ...
" }\n" + " }\n" +
" }\n" +
"}";
node.client().admin().indices().preparePutTemplate("general")
.setSource(GeneralTemplate).execute().actionGet(); //
executed after waiting for green status
My last resort is to manually create indexes with a index-exists check
beforehand, and providing those settings per index. I can verify this
works, but I'd really like to avoid that.
Thanks in advance.
Itamar.
--