不能在elasticsearch上请求数据


Can't request data on elasticsearch

我正在开发一个网站的连接日志图。日志由logstash解析,并通过elasticsearch提供。

我做了一些图表,没有什么突出的,也不努力,但工作。

星期五我启动了elasticsearch,当我发送查询时,我编写的每个获取数据的脚本都失败了。

我的第一个想法是我以某种方式修改了查询,所以我打印它并将其发送给elasticsearch(带插件头)。查询是正常的,我有结果。

我尝试从logstash和elasticsearch中清除日志,并重新开始从已知的良好数据中提供它们…

尝试查看配置是否有任何错误,使用工作备份,也不工作

作为最后的希望,我尝试打印PHP错误,并且我确实从elasticsearch的深处抛出了一个异常:

Fatal error: Uncaught exception 'Guzzle'Http'Exception'ServerErrorResponseException' with message 'Server error response [status code] 500 [reason phrase] 
Internal Server Error [url] http://localhost:9200/empreinte_index/mobile/_search' in /home/empreinte/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43 
Stack trace: 
#0 /home/empreinte/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(145): Guzzle'Http'Exception'BadResponseException::factory(Object(Guzzle'Http'Message'EntityEnclosingRequest), Object(Guzzle'Http'Message'Response)) 
#1 [internal function]: Guzzle'Http'Message'Request::onRequestError(Object(Guzzle'Common'Event), 'request.error', Object(Symfony'Component'EventDispatcher'EventDispatcher)) 
#2 /home/empreinte/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php(164): call_user_func(Array, Object(Guzzle'Common'Event), 'request.error', Object(Symfony'Component'EventDispatcher'EventDispatcher)) 
#3 /home/empreinte/vendor/symfony/event-dispatcher/Symfony in /home/empreinte/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/GuzzleConnection.php on line 238 

所以这似乎安慰我的想法,我的代码是好的,但我不知道我做错了什么,也不知道在哪里搜索。

下面是我使用的脚本的最小示例:
<?php
    echo "Days";
    require '/home/empreinte/vendor/autoload.php';
    $client = new Elasticsearch'Client();
    $Query['index'] = 'empreinte_index';
    $Query['type'] = 'web';
    echo ".";
    //Building the timeframe needed. For brevity, using hardcoded data.
    $timeframe = "{"from" : "1404165600", "to" : "1404252000" },{"from" : "1404252000", "to" : "1404338400" }";
    echo ".";
    $Query['body']='
    {
        "aggs" : 
        {
            "temps" : 
            {
                "range" : 
                {
                    "field" : "time",
                    "ranges" : ['.$timeframe.']
                },
                "aggs" : 
                { 
                    "new_users" : 
                    { 
                        "terms" : 
                        { 
                            "field" : "is_newuser" 
                        } 
                    }
                }
            }
        }   
    }';
    echo ".";
    $result = $client->search($Query);
    //Parse the data to get them in usable form for graphs
    echo "OK</br>";
?>

它输出"Days…",如果PHP设置为显示它,则例外。

(如果请求,我会发布配置文件和一些日志)。

我该如何解决这个问题?我在哪里可以找到一个类似的错误,我可以从中找到一个修复?误差是什么意思?

如果您检查响应,它看起来像一个请求问题:'request.error'

当您构造时间框架时,您使用双引号来构造字符串,但也在字符串内,这也可能是一个问题。

我真的不认为这是问题所在,但是试着去掉长时间戳周围的引号。

最后尝试打印查询,并尝试使用elasticsearch或head插件或kopf插件等工具进行查询。

希望有帮助