Is there a ping function available?

Hi, does the PHP API Version a PING Function has included? I know the PING
Function from Solar, its to check if the server is available and if not you
can make a Fallback. Or how is the best way to check if the elasticsearch
server is reachable? Regards and thanks Stefan.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/34326dc6-55bf-482e-8e64-f5a78f0590b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stefan,

If the TransportClient or NodeClient is set up as needed, then you can
easily wait for the cluster to be ready to use and let Elasticsearch do the
per-server discovery itself. At a high level (assuming this is part of some
class that includes private Client client;). Error reporting is minimal;
that can be easily adjusted depending on your needs:

public void waitForYellowStatus(TimeValue timeout, boolean waitForNode)
throws MyException
{
long startTime = System.currentTimeMillis();
TimeValue sleepTime = new TimeValue(2000);
for (;:wink:
{
try
{
client.admin().cluster().prepareHealth().setTimeout(timeout)
.setWaitForYellowStatus().execute().actionGet();
return;
}
catch (NoNodeAvailableException e)
{
if ((!waitForNode)
|| ((System.currentTimeMillis() - startTime) >
timeout.getMillis()))
throw new MyException("Cluster is not available: " + e);
sleep(sleepTime);
}
catch (ElasticsearchException e)
{
throw new MyException("Cluster is not ready: " + e);
}
}
}

Anyway, this works well for me. Hope it helps you!

Brian

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5bbb27ac-ead7-444a-ad35-ac807b604139%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Just issue a HTTP HEAD request against port 9200 of the host you want to
connect to and check for status 200

curl -I -XHEAD localhost:9200
HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8
Content-Length: 0

Or, if you want version information, use a HTTP GET request

curl -XGET localhost:9200
{
"status" : 200,
"name" : "Human Fly",
"version" : {
"number" : "1.1.0",
"build_hash" : "2181e113dea80b4a9e31e58e9686658a2d46e363",
"build_timestamp" : "2014-03-25T15:59:51Z",
"build_snapshot" : false,
"lucene_version" : "4.7"
},
"tagline" : "You Know, for Search"
}

Jörg

On Wed, Apr 23, 2014 at 5:47 PM, Stefan Kruse
info@all-around-shipping.dewrote:

Hi, does the PHP API Version a PING Function has included? I know the PING
Function from Solar, its to check if the server is available and if not you
can make a Fallback. Or how is the best way to check if the elasticsearch
server is reachable? Regards and thanks Stefan.

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/34326dc6-55bf-482e-8e64-f5a78f0590b1%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/34326dc6-55bf-482e-8e64-f5a78f0590b1%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEoJkA%2B4ris9RpBdCDO4OQdK-28HpxEK%2Bu--y6724237w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.