Ошибка при создании сопоставления эластичного поиска с упругой библиотекой - PullRequest
0 голосов
/ 29 ноября 2018

В моем приложении Laravel 5.7 я пытаюсь работать сasticsearch с composer.json:

{
    "require": {
        ...
        "elasticquent/elasticquent": "dev-master",
        ...
    },

Я читаю эту статью: https://appdividend.com/2018/06/30/laravel-elasticsearch-tutorial-example/

Я хочу начать ссоздание картографических и объемных данных.Для этого в моей модели app/Vote.php:

<?php

namespace App;

use DB; ... use Elasticquent\ElasticquentTrait; ... class Vote extends MyAppModel {
    use ElasticquentTrait; ...


    protected $table = 'votes';
    protected $primaryKey = 'id';
    public $timestamps = false;

    protected $fillable = ['name', 'slug', 'description', 'creator_id', 'vote_category_id', 'is_quiz', 'status', 'image'];
    protected $mappingProperties = array(

        'id'               => [
            'type' => 'integer',
            "analyzer" => "standard",
            'include_in_all' => FALSE
        ], //            'user'    => array(  // THERE would be nested data later //                'type' => 'object', //                'properties' => array( //                    'name'      => array('type' => 'string', 'include_in_all' => TRUE), //                'fullName'  => array('type' => 'string', 'include_in_all' => TRUE, 'boost' => 2) //                ), //            ),
        'name'             => [
            'type' => 'string',
            "analyzer" => "standard",
            'include_in_all' => TRUE
        ],
        'slug'             => [
            'type' => 'string',
            "analyzer" => "standard",
            'include_in_all' => TRUE
        ],
        'description'      => [
            'type' => 'string',
            "analyzer" => "standard",
            'include_in_all' => FALSE
        ],
        'created_at'       => [
            'type' => 'date',
            "analyzer" => "standard",
            'include_in_all' => FALSE
        ],


    public function getTableName(): string
    {
        return $this->table;
    }

    public function getPrimaryKey(): string
    {
        return $this->primaryKey;
    }



    public static function setVotesElasticMapping()
    {

        // Vote::deleteMapping();

        Vote::createIndex(/*$shards = null, $replicas = null*/);

        Vote::putMapping(/*$ignoreConflicts = true*/);

        Vote::addAllToIndex ();
    }
}

Но при вызове метода setVotesElasticMapping я получаю эту ошибку:

{"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index [select_vote/IxHrJ300SIWSZ_s12-jAJw] already exists","index_uuid":"IxHrJ300SIWSZ_s12-jAJw","index":"select_vote"}],"type":"resource_already_exists_exception","reason":"index [select_vote/IxHrJ300SIWSZ_s12-jAJw] already exists","index_uuid":"IxHrJ300SIWSZ_s12-jAJw","index":"select_vote"},
"status":400}

Это ясно, так как я создал индекс раньшеи "select_vote" - это "default_index" в config/elasticquent.php файле.

При раскомментировании строки:

Vote::deleteMapping();

Я получаю эту ошибку:

Elasticsearch \ Common \ Exceptions \ BadRequest400Exception (405)
{"error":"Incorrect HTTP method for uri [/select_vote/votes/_mapping] and method [DELETE], allowed: [PUT, GET, POST]","status":405}

Можете ли вы сказатьпочему я получаю эту ошибку и как ее исправить?Я думаю, в любом случае мне нужно вызвать этот метод, скажем, если я переделал структуру отображения.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...