首页 文章

Laravel 5 - Elasticquent / ElasticSearch Missing404Exception with(Re)Mapping

提问于
浏览
0

我遇到了一个“小问题”:s一切运行良好,直到我从新服务器移动,现在我无法映射我的数据库 .

我使用Laravel 5上的弹性库.Elasticsearch工作,索引工作,但我不能正确地映射我的结果与我的工匠commande .

我的命令调用一个库,我在库中使用Elasticquent Trait .

首先,我调用我的reMapAll()方法 . 它找到“应用程序”,每个应用程序都有自己的索引 .

public function ReMapAll() {

    $listApplication = \DB::table('application')->select('id')->get();

    foreach($listApplication as $k=>$v) {
        $this->initIndex($v->id);

         foreach($this->models as $k=>$v) {
            $class = '\App\Models\\'.$v;

            if($class::mappingexists()) {
                $class::deleteMapping();
            }
        }

    }
    $map = $this->MapAll();

    $this->clearIndex(null,null,$map);

    return;
}

根据日志,错误出现在$ class :: deleteMapping();

我的命令显示错误

[Elasticsearch\Common\Exceptions\Missing404Exception]
{"found":false,"_index":"index_application_1","_type":"product","_id":"_mapping","_version":1,"_shards":{"total":2,"successful":1,"failed":0}}

[Guzzle\Http\Exception\ClientErrorResponseException]
Client error response
[status code] 404
[reason phrase] Not Found
[url] http://localhost:9200/index_application_1/product/_mapping

我真的不明白这个错误的含义 . 如果我做 curl http://localhost:9200/index_application_1/product/_mapping ,它的工作!

完整的堆栈跟踪:

[2015-12-15 16:02:04] local.ERROR: exception 'Guzzle\Http\Exception\ClientErrorResponseException' with message 'Client error response
[status code] 404
[reason phrase] Not Found
[url] http://localhost:9200/index_application_1/product/_mapping' in /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43

Stack trace:
#0 /var/www/clients/client1/web2/web/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 /var/www/clients/client1/web2/web/vendor/symfony/event-dispatcher/EventDispatcher.php(181): call_user_func(Array, Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#3 /var/www/clients/client1/web2/web/vendor/symfony/event-dispatcher/EventDispatcher.php(46): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'request.error', Object(Guzzle\Common\Event))
#4 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(589): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('request.error', Object(Guzzle\Common\Event))
#5 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(378): Guzzle\Http\Message\Request->processResponse(Array)
#6 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Message/EntityEnclosingRequest.php(49): Guzzle\Http\Message\Request->setState('complete', Array)
#7 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(303): Guzzle\Http\Message\EntityEnclosingRequest->setState('complete', Array)
#8 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(257): Guzzle\Http\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array)
#9 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(240): Guzzle\Http\Curl\CurlMulti->processMessages()
#10 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(224): Guzzle\Http\Curl\CurlMulti->executeHandles()
#11 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(111): Guzzle\Http\Curl\CurlMulti->perform()
#12 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMultiProxy.php(94): Guzzle\Http\Curl\CurlMulti->send()
#13 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php(284): Guzzle\Http\Curl\CurlMultiProxy->send()
#14 /var/www/clients/client1/web2/web/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(198): Guzzle\Http\Client->send(Object(Guzzle\Http\Message\EntityEnclosingRequest))
#15 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/GuzzleConnection.php(198): Guzzle\Http\Message\Request->send()
#16 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/GuzzleConnection.php(104): Elasticsearch\Connections\GuzzleConnection->sendRequest(Object(Guzzle\Http\Message\EntityEnclosingRequest), NULL)
#17 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(166): Elasticsearch\Connections\GuzzleConnection->performRequest('DELETE', '/index_applicat...', Array, NULL)
#18 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php(86): Elasticsearch\Transport->performRequest('DELETE', '/index_applicat...', Array, NULL)
#19 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/IndicesNamespace.php(821): Elasticsearch\Endpoints\AbstractEndpoint->performRequest()
#20 /var/www/clients/client1/web2/web/vendor/fairholm/elasticquent/src/ElasticquentTrait.php(453): Elasticsearch\Namespaces\IndicesNamespace->deleteMapping(Array)
#21 /var/www/clients/client1/web2/web/app/Library/Tools/ElasticSearch.php(71): App\Models\Eloquent::deleteMapping()
#22 /var/www/clients/client1/web2/web/app/Console/Commands/ElasticSearch.php(66): App\Library\Tools\ElasticSearch->ReMapAll()
#23 [internal function]: App\Console\Commands\ElasticSearch->handle()
#24 /var/www/clients/client1/web2/web/vendor/laravel/framework/src/Illuminate/Container/Container.php(503): call_user_func_array(Array, Array)
#25 /var/www/clients/client1/web2/web/vendor/laravel/framework/src/Illuminate/Console/Command.php(150): Illuminate\Container\Container->call(Array)
#26 /var/www/clients/client1/web2/web/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /var/www/clients/client1/web2/web/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /var/www/clients/client1/web2/web/vendor/symfony/console/Application.php(838): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 /var/www/clients/client1/web2/web/vendor/symfony/console/Application.php(189): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\ElasticSearch), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /var/www/clients/client1/web2/web/vendor/symfony/console/Application.php(120): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /var/www/clients/client1/web2/web/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /var/www/clients/client1/web2/web/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 {main}

Next exception 'Elasticsearch\Common\Exceptions\Missing404Exception' with message '{"found":false,"_index":"index_application_1","_type":"product","_id":"_mapping","_version":1,"_shards":{"total":2,"successful":1,"failed":0}}' in /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/GuzzleConnection.php:271
Stack trace:
#0 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/GuzzleConnection.php(203): Elasticsearch\Connections\GuzzleConnection->process4xxError(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Exception\ClientErrorResponseException), NULL)
#1 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/GuzzleConnection.php(104): Elasticsearch\Connections\GuzzleConnection->sendRequest(Object(Guzzle\Http\Message\EntityEnclosingRequest), NULL)
#2 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(166): Elasticsearch\Connections\GuzzleConnection->performRequest('DELETE', '/index_applicat...', Array, NULL)
#3 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php(86): Elasticsearch\Transport->performRequest('DELETE', '/index_applicat...', Array, NULL)
#4 /var/www/clients/client1/web2/web/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/IndicesNamespace.php(821): Elasticsearch\Endpoints\AbstractEndpoint->performRequest()
#5 /var/www/clients/client1/web2/web/vendor/fairholm/elasticquent/src/ElasticquentTrait.php(453): Elasticsearch\Namespaces\IndicesNamespace->deleteMapping(Array)
#6 /var/www/clients/client1/web2/web/app/Library/Tools/ElasticSearch.php(71): App\Models\Eloquent::deleteMapping()
#7 /var/www/clients/client1/web2/web/app/Console/Commands/ElasticSearch.php(66): App\Library\Tools\ElasticSearch->ReMapAll()
#8 [internal function]: App\Console\Commands\ElasticSearch->handle()
#9 /var/www/clients/client1/web2/web/vendor/laravel/framework/src/Illuminate/Container/Container.php(503): call_user_func_array(Array, Array)
#10 /var/www/clients/client1/web2/web/vendor/laravel/framework/src/Illuminate/Console/Command.php(150): Illuminate\Container\Container->call(Array)
#11 /var/www/clients/client1/web2/web/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/clients/client1/web2/web/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/clients/client1/web2/web/vendor/symfony/console/Application.php(838): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/clients/client1/web2/web/vendor/symfony/console/Application.php(189): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\ElasticSearch), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/clients/client1/web2/web/vendor/symfony/console/Application.php(120): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/clients/client1/web2/web/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/clients/client1/web2/web/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 {main}

1 回答

  • 2

    我的猜测是你使用ES 2.0和Elasticquent,而后者只支持ES v1.x.从ES 2.0开始,删除映射类型(即使用 deleteMapping() )是no longer supported .

    你有三个解决方案:

    • 您删除索引并重新创建它

    • 您降级到ES 1.7.4

    • 您使用另一个支持Elasticsearch 2.0的Laravel软件包

相关问题