Hello!
Look here: http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html
Basically you have three cluster health status cases - red says not all primary shards are allocated and thus you may experience the exception you saw with no active shards. Than the yellow mean that primary shards are allocated, but one or more replicas are not. The green one means that both primaries and replicas are allocated.
You can set your code to wait for yellow status. However it may take time for ElasticSearch to get to that state and how long depends on your deployment.
--
Regards,
Rafał Kuć
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch
But this takes some time (like 30 sec)
Could I make some less drastic requirements and still get the job done?
2013/2/3 Rafał Kuć <r.kuc@solr.pl>
Hello!
Maybe you can just wait for yellow or green status ? If you can just execute a code like:
client.admin().cluster().health(new ClusterHealthRequest().waitForGreenStatus()).actionGet();
--
Regards,
Rafał Kuć
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch
I have figured out I can do this gets and searches operations using only one node created in Java (I use default data node)
but I have to wait after gateway recovery process will end AND until probably shards will be located in my one node.
So if I will run my Jave client like this:
Node node = nodeBuilder().node();
Client client = node.client();
GetResponse response = client.prepareGet("twitter", "tweet", "2")
.execute()
.actionGet();
I will get this exception ...
lut 03, 2013 6:33:35 PM org.elasticsearch.node
INFO: [Grog the God-Crusher] {0.20.2}[6756]: initializing ...
lut 03, 2013 6:33:35 PM org.elasticsearch.plugins
INFO: [Grog the God-Crusher] loaded [], sites []
lut 03, 2013 6:33:37 PM org.elasticsearch.node
INFO: [Grog the God-Crusher] {0.20.2}[6756]: initialized
lut 03, 2013 6:33:37 PM org.elasticsearch.node
INFO: [Grog the God-Crusher] {0.20.2}[6756]: starting ...
lut 03, 2013 6:33:37 PM org.elasticsearch.transport
INFO: [Grog the God-Crusher] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.0.101:9300]}
lut 03, 2013 6:33:40 PM org.elasticsearch.cluster.service
INFO: [Grog the God-Crusher] new_master [Grog the God-Crusher][kBlV01OYSBuyQvRk3my19w][inet[/192.168.0.101:9300]], reason: zen-disco-join (elected_as_master)
lut 03, 2013 6:33:40 PM org.elasticsearch.discovery
INFO: [Grog the God-Crusher] elasticsearch/kBlV01OYSBuyQvRk3my19w
lut 03, 2013 6:33:40 PM org.elasticsearch.http
INFO: [Grog the God-Crusher] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.0.101:9200]}
lut 03, 2013 6:33:40 PM org.elasticsearch.node
INFO: [Grog the God-Crusher] {0.20.2}[6756]: started
Exception in thread "main" org.elasticsearch.action.NoShardAvailableActionException: [twitter][3] No shard available for [[twitter][tweet][2]: routing [null]]
And for example if I will run Java client with more time to Gateway recover and alocate shards like this:
Node node = nodeBuilder().node();
Client client = node.client();
Thread.sleep(2000);
GetResponse response = client.prepareGet("twitter", "tweet", "2")
.execute()
.actionGet();
.
.
.
INFO: [Time Bomb] {0.20.2}[6164]: started
lut 03, 2013 6:38:41 PM org.elasticsearch.gateway
INFO: [Time Bomb] recovered [20] indices into cluster_state
I wont get any exception and all will work ok.
Can I use any API to find out when I restart cluster (Gateway recovery) to check if all alocating shards process is done?
If so I could then execute safely operations like gets and searches without to be worry about any shard exeption etc.
W dniu sobota, 2 lutego 2013 16:05:01 UTC+1 użytkownik David Pilato napisał:
Hey,
Look at: https://github.com/elasticsearchfr/hands-on/tree/answers
BTW, you have first to create documents before being able to search for them.
HTH
--
David
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 2 févr. 2013 à 15:54, JJack_PL <jjac...@gmail.com> a écrit :
When I use Java client by:
Node node = nodeBuilder().node();
Client client = node.client();
and using this client to "get operation" like:
GetResponse response = client.prepareGet("twitter", "tweet", "1")
.execute()
.actionGet();
or "search operation" like:
SearchResponse response = client.prepareSearch("test")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(termQuery("multi", "test"))
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();
I got those exceptions:
Exception in thread "main" org.elasticsearch.action.NoShardAvailableActionException:
[twitter][2] No shard available for [[twitter][tweet][1]: routing [null]]
Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs],
total failure; shardFailures {[na][twitter][0]: No active shards}{[na][twitter][1]: No active shards}{[na][twitter][2]:
No active shards}{[na][twitter][3]: No active shards}{[na][twitter][4]: No active shards}
Can I do those gets ans searches by my Java client without running first ES started in windows?
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.