跟着慕课网学习《Laravel快速开发简书》,搜索一章的时候,创建模板出现的错误总结:
模板文件:

<?phpnamespace App\Console\Commands;use GuzzleHttp\Client;
use Illuminate\Console\Command;class ESInit extends Command
{/*** The name and signature of the console command.** @var string*/protected $signature = 'es:init';/*** The console command description.** @var string*/protected $description = '初始化 ES ';/*** Create a new command instance.** @return void*/public function __construct(){parent::__construct();}/*** Execute the console command.** @return mixed*/public function handle(){//TODO:创建template$client = new Client();$url = config('scout.elasticsearch.hosts')[0] . '/_template/tmp';$client->delete($url);$param = ['json' => ['template' => config('scout.elasticsearch.index'),'settings' => ['number_of_shards' => 1],'mappings' => ['_default_' => ['_all' => ['enabled' => true],'dynamic_templates' => [['strings' => ['match_mapping_type' => 'string','mapping' => ['type' => 'text','analyzer' => 'ik_smart',//文本分析'ignore_above' => 256,'fields' => ['keyword' => ['type' => 'keyword']]]]]]]]]];$client->put($url, $param);$this->info("=====创建模板成功=====");//TODO:创建index$url = config('scout.elasticsearch.hosts')[0] . '/' . config('scout.elasticsearch.index');$client->put($url, ['json' => ['settings' => ['refresh_interval' => '5s','number_of_shards' => 1,'number_of_replicas' => 0,],'mappings' => ['_default_' => ['_all' => ['enabled' => false]]]]]);$this->info("=====创建索引成功=====");}
}

执行命令:

php artisan es:init

报错:

Client error: `PUT http://127.0.0.1:9200/_template/tmp` resulted in a `400 Bad Request` response:{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: (truncated...)


原因:
jdk1.9 版本问题,jdk1.8则没有这个问题出现。
解决办法:

<?phpnamespace App\Console\Commands;use GuzzleHttp\Client;
use Illuminate\Console\Command;class ESInit extends Command
{/*** The name and signature of the console command.** @var string*/protected $signature = 'es:init';/*** The console command description.** @var string*/protected $description = 'init laravel es for post';/*** Create a new command instance.** @return void*/public function __construct(){parent::__construct();}/*** Execute the console command.** @return mixed*/public function handle(){// 创建template$client = new Client();$url = config('scout.elasticsearch.hosts')[0] . '/_template/tmp';try {$client->delete($url);} catch (\Exception $e) {$this->info("===delete模版出现错误==" . $e->getMessage());}$param = ['json' => ['template' => config('scout.elasticsearch.index'),'mappings' => ['posts' => ['properties' => ['title' => ['type' => 'text','analyzer' => 'ik_max_word',],'content' => ['type' => 'text','analyzer' => 'ik_max_word',]]]],],];try {$client->put($url, $param);} catch (\Exception $e) {$this->info("===put模版出现错误==" . $e->getMessage());}$this->info("========= 创建模版成功 ========");// 创建index$url = config('scout.elasticsearch.hosts')[0] . '/' . config('scout.elasticsearch.index');try {$client->delete($url);} catch (\Exception $e) {$this->info("===delete索引出现错误==" . $e->getMessage());}$param = ['json' => ['settings' => ['refresh_interval' => '5s','number_of_shards' => 1,'number_of_replicas' => 0,],'mappings' => ['posts' => ['_all' => ['enabled' => false]]]]];try {$client->put($url, $param);} catch (\Exception $e) {$this->info("===put索引出现错误==" . $e->getMessage());}$this->info("========= 创建索引成功 ========");}
}

ES新建模板时的错误 Client error: `PUT http://127.0.0.1:9200/_template/tmp` resulted in a `400 Bad Request`相关推荐

  1. CMake编译VS工程,生成解决方案时遇到错误:error MSB3073: 命令“setlocal”

    一.问题描述 CMake编译ZXing-cpp,编译成功后,打开项目,x86(win32)平台生成解决方案成功,但在x64平台,debug模式下报错:error MSB3073: 命令"se ...

  2. Navicat连接数据库成功,新建查询时提示错误“Cannot create file ……”

    Navicat连接数据库成功,新建查询时提示错误"Cannot create file --" 原因:编辑连接{高级}<设置位置>被修改,该oci.dll不正确 解决方 ...

  3. 安装vs2008中文时出现错误Write error in the file

    安装vs2008中文时出现错误Write error in the file VS2008TeamSuite90DayTrialCHSX1429243.iso. Probably the disk i ...

  4. kubeadm join时出现错误:[ERROR Port-10250]: Port 10250 is in use [ERROR FileAvailable--etc-kubernetes-pki

    kubeadm join时出现错误:[ERROR Port-10250]: Port 10250 is in use:[ERROR FileAvailable--etc-kubernetes-pki- ...

  5. git提交代码时出现错误:error : unpack failed : error Missing commit XXX,

    Git 提交出错 git提交代码时出现错误:error : unpack failed : error Missing commit 384ccb27185a68ec9c0d0ce948e7432d6 ...

  6. iar使用秉火DAP仿真时出现错误 Download error at 0x08000000: downloading into non-writable memory.

    在学习野火stm32f103开发板时,iar使用秉火DAP仿真时出现错误 Download error at 0x08000000: downloading into non-writable mem ...

  7. Latex中表格中固定表格宽度时出现错误“LaTeX Error: Illegal character in array arg.”

    Latex中表格中固定表格宽度时出现错误"LaTeX Error: Illegal character in array arg.",如下: \documentclass{arti ...

  8. mysql创建表格显示1064错误_尝试创建表时出现错误1064(Error 1064 when trying to create a table)...

    尝试创建表时出现错误1064(Error 1064 when trying to create a table) 这是代码: create table `team`.`User`( `UserID` ...

  9. 解决twine upload时HTTPError: 403 Client Error: Invalid or non-existent authentication information.

    正在自学Ninad Sathaye - Learning Python Application Development (2016, Packt Publishing - ebooks Account ...

最新文章

  1. AAAI2020| 超低精度量化BERT,UC伯克利提用二阶信息压缩神经网络
  2. linux 手动释放内存
  3. 趣头条将获得阿里1.71亿美元的可转债,为期三年...
  4. The 'microsoft.jet.oledb.4.0' provider is not registered on the local machin
  5. 高性能线程间队列 DISRUPTOR 简介
  6. MongoDB使用记录
  7. 【渝粤教育】国家开放大学2018年秋季 0273-21T中国现代文学 参考试题
  8. Linux编译安装PHP Mysql Nginx
  9. win7系统可以禁止的服务器,win7旗舰版怎么禁用不必要的系统服务项
  10. 网站被国外IP攻击 禁止海外IP访问网站的解决办法
  11. linux 剪贴板_如何在Linux上使用剪贴板管理器
  12. 明天过节,给将来的程序员们一个神奇的名单。兄弟们看准了(不说他们好坏,只求别去了才知道是传说中的外包)
  13. part-17 从开环增益曲线谈到运放稳定性
  14. python强行终止程序_python终止程序的方法
  15. Dex.top“50计划”新玩法,能否让行业格局重新洗牌?
  16. 获取自己win10系统的产品密匙
  17. 英语学习口诀大全be 的用法口诀
  18. 工作之外的闲暇时光(玩魔方)
  19. 洛谷P4735 最大异或和
  20. 像电影里黑客高手一样敲代码攻击入侵网站(模拟)

热门文章

  1. 美团每日红包 青龙面板
  2. 【python OpenCV3.3图片处理教程】-图像基本运算、色彩空间、ROI、模糊去噪
  3. 深入浅出再谈Unity内存泄漏
  4. 爱奇艺“技术气氛组”上线!点击查收你的专属AI拜年新姿势
  5. java小时钟实验报告_JAVA实验报告(运用JavaFx实现时钟动画).doc
  6. torch模块常用方法总结
  7. ctf比赛的三种形式
  8. Linux电源管理(2)_Generic PM之基本概念和软件架构(蜗窝科技,www.wowotech.net)
  9. 【STM32】BootLoader介绍、编写 以及 OTA常见方案分析(差分升级 全量升级 AB面升级)
  10. 墨海醉笔,又流逝了多少华年?