0
votes

I'm stuck on a "little" issue :s All worked well until i move from a new server and now i can't map my database.

I use the elasticquent library on Laravel 5. Elasticsearch works, indexing works but i can't map correctly my result with my artisan commande.

My command call a library where i use the Elasticquent Trait in my library.

First, i call my reMapAll() method. It find the "application", each application has is own index.

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;
}

According to the log, the error appear with $class::deleteMapping();

The error shown with my command

[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

I don't really understand the meaning of this error. If i make curl http://localhost:9200/index_application_1/product/_mapping, it's work !

The complete stack trace :

[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

1 Answers

2
votes

My guess is that you're using ES 2.0 with Elasticquent and the latter does only support ES v1.x. Deleting a mapping type (i.e. using deleteMapping()) is no longer supported since ES 2.0.

You have three solutions:

  1. You delete the index and re-create it
  2. You downgrade to ES 1.7.4
  3. You use another Laravel package which supports Elasticsearch 2.0