Scout 结合 Elasticsearch8.1.0导入数据出现问题(求用过es8.1.0的大佬救命!!!)

laravel版本 5.7.24

ElasticSearch版本 8.1.0

扩展包是babenkoivan/scout-elasticsearch-driver最新

其他配置均已完成,只是在导入文章数据时出现以下报错

  Elasticsearch\Common\Exceptions\BadRequest400Exception  : {"error":"no handler found for uri [/articles_write/articles/_mapping?include_type_name=true] and method [PUT]"}

感觉include_type_name=true是个重要的错误,看了一些参考说ES7以后include_type_name默认为false在8以后直接移除了,实在不知道怎么修改,特此询问社区大佬,请求帮助,并帮小弟看看是否还有其他错误 比如 method [PUT] 这块

模型配置如下

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use ScoutElastic\Searchable;

class Articles extends Model
{
    use Searchable;
    protected $table = 'articles';
    protected $indexConfigurator = ArticlesIndexConfigurator::class;

    protected $mapping = [
        'include_type_name' => true,
        'properties' => [
            'title' => [
                'type' => 'text',
                'analyzer' => 'ik_max_word'
            ],
            'content' => [
                'type' => 'text',
                'analyzer' => 'ik_smart'
            ],
            'keyword' => [
                'type' => 'text',
                'analyzer' => 'ik_max_word'
            ],
            'desc' => [
                'type' => 'text',
                'analyzer' => 'ik_max_word'
            ],

        ]
    ];


    public function toSearchableArray()
    {
        return [
            'title'=> $this->title,
            'content' => $this->content,
            'keyword' => $this->keyword,
            'desc' => $this->desc,
        ];
    }
}
一个偏向心理学即将转向产品的码农
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
最佳答案

搞了半天是babenkoivan/scout-elasticsearch-drive扩展包目前不支持ES8.0以上,因为扩展包支持的es-php最高版本为7.11.0,要用8.0以上的话建议换成Tamayo/laravel-scout-elastic,或者要改动扩展包源码,因为本人能力和时间有限,ES版本就退回7.16.3了

2年前 评论
讨论数量: 7

补一下完整报错

   Elasticsearch\Common\Exceptions\BadRequest400Exception  : {"error":"no handler found for uri [/articles_write/articles/_mapping?include_type_name=true] and method [PUT]"}

  at /www/wwwroot/blog/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:675
    671|             $exception = new ScriptLangNotSupportedException($responseBody. $statusCode);
    672|         } elseif ($statusCode === 408) {
    673|             $exception = new RequestTimeout408Exception($responseBody, $statusCode);
    674|         } else {
  > 675|             $exception = new BadRequest400Exception($responseBody, $statusCode);
    676|         }
    677| 
    678|         $this->logRequestFail($request, $response, $exception);
    679| 

  Exception trace:

  1   Elasticsearch\Connections\Connection::process4xxError([])
      /www/wwwroot/blog/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:333

  2   Elasticsearch\Connections\Connection::Elasticsearch\Connections\{closure}()
      /www/wwwroot/blog/vendor/react/promise/src/FulfilledPromise.php:28

  3   React\Promise\FulfilledPromise::then(Object(Closure))
      /www/wwwroot/blog/vendor/ezimuel/ringphp/src/Future/CompletedFutureValue.php:55

  4   GuzzleHttp\Ring\Future\CompletedFutureValue::then(Object(Closure))
      /www/wwwroot/blog/vendor/ezimuel/ringphp/src/Core.php:341

  5   GuzzleHttp\Ring\Core::proxy(Object(GuzzleHttp\Ring\Future\CompletedFutureArray), Object(Closure))
      /www/wwwroot/blog/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:345

  6   Elasticsearch\Connections\Connection::Elasticsearch\Connections\{closure}(Object(Elasticsearch\Connections\Connection), Object(Elasticsearch\Transport), [])
      /www/wwwroot/blog/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:241

  7   Elasticsearch\Connections\Connection::performRequest("PUT", "/articles_write/articles/_mapping", ["true"], "{"articles":{"properties":{"title":{"type":"text","analyzer":"ik_max_word"},"content":{"type":"text","analyzer":"ik_smart"},"keyword":{"type":"text","analyzer":"ik_max_word"},"desc":{"type":"text","analyzer":"ik_max_word"}}}}", [], Object(Elasticsearch\Transport))
      /www/wwwroot/blog/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php:110

  8   Elasticsearch\Transport::performRequest("PUT", "/articles_write/articles/_mapping", ["true"], [], [])
      /www/wwwroot/blog/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/AbstractNamespace.php:63

  9   Elasticsearch\Namespaces\AbstractNamespace::performRequest(Object(Elasticsearch\Endpoints\Indices\PutMapping))
      /www/wwwroot/blog/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/IndicesNamespace.php:766

  10  Elasticsearch\Namespaces\IndicesNamespace::putMapping(["true"])
      /www/wwwroot/blog/vendor/babenkoivan/scout-elasticsearch-driver/src/Console/ElasticUpdateMappingCommand.php:57

  11  ScoutElastic\Console\ElasticUpdateMappingCommand::handle()
      /www/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29

  12  call_user_func_array([])
      /www/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29

  13  Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
      /www/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87

  14  Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
      /www/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31

  15  Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
      /www/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php:572

  16  Illuminate\Container\Container::call()
      /www/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Console/Command.php:183

  17  Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      /www/wwwroot/blog/vendor/symfony/console/Command/Command.php:255

  18  Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      /www/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Console/Command.php:170

  19  Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /www/wwwroot/blog/vendor/symfony/console/Application.php:1009

  20  Symfony\Component\Console\Application::doRunCommand(Object(ScoutElastic\Console\ElasticUpdateMappingCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /www/wwwroot/blog/vendor/symfony/console/Application.php:273

  21  Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /www/wwwroot/blog/vendor/symfony/console/Application.php:149

  22  Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /www/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Console/Application.php:89

  23  Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /www/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122

  24  Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /www/wwwroot/blog/artisan:37
2年前 评论

索引都建完了就是导入不进去(索引不知道怎么的还有个别名)

file

2年前 评论

搞了半天是babenkoivan/scout-elasticsearch-drive扩展包目前不支持ES8.0以上,因为扩展包支持的es-php最高版本为7.11.0,要用8.0以上的话建议换成Tamayo/laravel-scout-elastic,或者要改动扩展包源码,因为本人能力和时间有限,ES版本就退回7.16.3了

2年前 评论

我去 我要是早点看到就好了,我也是用的es8.4.1,一样的问题,死活导不进去,浪费了2天时间,这个报错后面还有报错,早知道就用es 7.x的版本了, 这是那两个报错截图,我的版本是 laravel8 + es8

file

file

如果碰到了,直接用es7.x的版本吧。。。

2年前 评论
working (楼主) 2年前
on_the_way_liuda (作者) 2年前
working (楼主) 2年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!