azure - elasticsearch php api with multiple hosts -


i followed link create elasticsearch 2 nodes cluster on azure: this link

the installation , configuring went good.

when started check cluster found strange behaviour php client.

i declared 2 hosts in client:

$elsearch_server = array("dns1:9200","dns2:9200"); $params = array(); $params['hosts'] = $elsearch_server; $dstel = new elasticsearch\client($params); 

the excpected behaviour try insert documents "dns1" , if fails automatically change "dns2". but, reason when 1 of servers down on insertion php client throws exception couldn't connect host , only.

is there way cause client automatically choose online server?

thnx

solution: after debugging the elasticsearch php client found retry mechansim allows client jump next server pool if previous down. this mechanism disabled default

to enable mechanism need initialize client parameter called retries:

$params = array(); $params['hosts'] = $elsearch_server;     $params['retries'] = count($elsearch_server); $dstel = new elasticsearch\client($params); 

hope guys


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -