我对ElasticSearch很陌生,现在只想搞清楚一些事情,但这是一个问题。在更改服务器的所有麻烦之后,我们迁移了节点,但其中一个节点中有一些丢失的数据。我们有两个节点,两个节点都有相同ID的记录。在第一个一切都很好,但在第二个一些记录似乎缺失。例如,如果我发送这样的请求:
GET /fnh_detailbeta/main/61UkVww8QGu093RirFG84A
我将收到以下错误(在Marvel - Sense中)
{
"error": "NoShardAvailableActionException[[fnh_detailbeta][0] null]",
"status": 503
}
所以,我现在要做的是通过ElasticSearch PHP将节点1中的所有记录与节点2中的记录进行比较。这是我正在尝试运行的PHP:
<?php
require '../connector/vendor/autoload.php';
$number = 1;
$params = array();
$params['hosts'] = array (
'146.185.164.121:9200', // IP + Port
);
$client = new Elasticsearch\Client($params);
$getParams = array();
$getParams['index'] = 'fnh_mainbeta';
$getParams['type'] = 'main';
//REQUEST AMOUNT
$json = '{"query": {"match_all": {}},"size": 1,"from":'.$number.'}';
$getParams['body'] = $json;
$retDoc = $client->search($getParams);
$total = $retDoc['hits']['total'];
//END OF REQUEST AMOUNT
//REQUEST ID
for ($i = 1; $i <= $total; $i++) {
$json = '{"query": {"match_all": {}},"size": 1,"from":'.$number.'}';
$getParams = array();
$getParams['index'] = 'fnh_mainbeta';
$getParams['type'] = 'main';
$getParams['body'] = $json;
$getParams['ignore'] = 503;
$getParams['ignore'] = 404;
$retDoc = $client->search($getParams);
$found_id = $retDoc['hits']['hits'][0]['_id'];
echo $found_id;
//REGUEST SECOND DB
$getParams = array();
$getParams['index'] = 'fnh_detailbeta';
$getParams['type'] = 'main';
$getParams['id'] = '61UkVww8QGu093RirFG84A';
$retDoc = $client->get($getParams);
$found_id_two = $retDoc['_id'];
echo $found_id_two;
//END OF REQUEST SECOND DB
$number++;
sleep(1);
};
//END OF REQUEST AMOUNT
现在还没有完成,但是我得到了退出脚本的致命错误:
Fatal error: Uncaught exception 'Guzzle\Http\Exception\ServerErrorResponseException' with message 'Server error response
[status code] 503
[reason phrase] Service Unavailable
当NoShardAvailableActionException [[fnh_detailbeta] [0] null]时出现此错误...所以,问题是: 在不停止PHP执行的情况下,捕获此错误的最佳方法是什么(如IF错误THEN echo“error”)。换句话说 - 我想确定此错误,删除此记录并进一步比较节点。
任何帮助将不胜感激!