Elasticsearchs的安装/laravel-scout和laravel-scout-elastic的安装
安装:
https://github.com/medcl/elasticsearch-rtf
先下载包
下载解压后
cd elasticsearch-rtf-master
ll
bin/elasticsearch-plugin list 这里会显示所有的插件
过滤插件
bin/elasticsearch-plugin list > /tmp/plugin.log
vim /tmp/plugin.log 在这里面把我们需要的analysis-ik这个插件去掉
cat /tmp/plugin.log|xargs -I {} bin/elasticsearch-plugin remove {} //删除
bin/elasticsearch-plugin list //查看
bin/elasticsearch -d //启动
ps aux|grep java
查看是否启动:: vim logs/elasticsearch.log
127.0.0.1:9200
安装laravel使用elastic的包
安装laravel/scout 查看文档地址 https://laravel-china.org/docs/laravel/5.4/scout/1276

接下来安装laravel-scout-elastic
执行这个
composer require tamayo/laravel-scout-elastic

报这个错,我查了下,最终找到原因,是我安装的
laravel/scout版本太高了,我给降到5.0就ok啦 后面的按照这个网址走就行啦 https://github.com/ErickTamayo/laravel-scout-elastic 来到项目中的config\scout.php中修改配置

'elasticsearch' => [
'index' => env('ELASTICSEARCH_INDEX', 'laravel'),
'hosts' => [
env('ELASTICSEARCH_HOST', 'http://localhost'),
],
]
就ok啦,主要查看文档,!!!!
使用laravel的command实现搜索引擎索引和模板的建立
分为三步走:
创建Command
php artsan make:command ESInit

然后来到下面这个类

然后查看php artisan 就会看到 ps:init命令
编辑handle
在ESInit.php文件中,添加文件
use GuzzleHttp\Client;
需要安装这个插件
composer require GuzzleHttp/guzzle
public function handle()
{
//创建template
$client = new Client();
// 创建模版
$url = config('scout.elasticsearch.hosts')[0] . '/_template/tmp';
$client->put($url, [
'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'
]
]
]
]
]
]
]
]
]
]);
$this->info("=====创建模板成功====="); $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("=====创建索引成功====="); }
挂载到laravel的artisan中去
然后这边,我们来到控制台
php artisan es:init 就ok了
Elasticsearchs的安装/laravel-scout和laravel-scout-elastic的安装的更多相关文章
- Laravel 5.5 文档 ] 快速入门 —— 安装配置篇
服务器要求 Laravel 框架对PHP版本和扩展有一定要求,不过这些要求 Laravel Homestead 都已经满足了,不过如果你没有使用 Homestead 的话(那真是一件很遗憾的事情),有 ...
- Laravel 调试利器 —— Laravel Debugbar 扩展包安装及使用教程
1.简介 Laravel Debugbar 在 Laravel 5 中集成了 PHP Debug Bar ,用于显示调试及错误信息以方便开发.该扩展包包含了一个 ServiceProvider 用于注 ...
- Laravel 5使用Laravel Excel实现Excel/CSV文件导入导出的功能详解
1.简介 本文主要给大家介绍了关于Laravel 5用Laravel Excel实现Excel/CSV文件导入导出的相关内容,下面话不多说了,来一起看看详细的介绍吧. Laravel Excel 在 ...
- Windows无法完成安装,若要在此计算机上安装Windows,请中心启动安装。
现在安装系统已经很简单了,我觉得U盘启动的话两步就差不多了, 壹:设置BIOS,将U盘启动作为系统默认启动选项 贰:直接进去大白菜之类的,一键安装... 今天终于看到第三部了, 报错:Windows无 ...
- 安装了VS2012 还有Update4 我的Silverlight5安装完后 我的Silverlight4项目打不开
安装了VS2012 还有Update4 我的Silverlight5安装完后 我的Silverlight4项目打不开 求助 不知道是哪里出问题了 我的Silverlihgt4项目一直报错 无法打开 ...
- 2016最新 wamp2.5+windows 10安装CoedSgniffer代码格式检查:5分钟安装 30分钟入门和浏览常用命令
14:59 2016/1/112016最新 wamp2.5+windows 10安装CoedSgniffer代码格式检查:注意问题:1.手动安装2.5.0和pear安装方式都成功但是执行时无任何反映, ...
- php通用安装程序,导入数据文件(.sql)的安装程序
php通用安装程序,导入数据文件(.sql)的安装程序 该程序只需要1个php文件 和 1个数据文件,很方便调用.install/index.php 程序文件install/mycms ...
- caffe 安装在win 7 vs2015 无gpu的安装方式-是无法安装 的
网上多数是vs2012或者vs2013上安装方式,带NA-显卡的需要安装CUDA7.5,安装cuDNN4,cuDNN. 一 :下载caffe源码(microsoft版) 下载地址:https://gi ...
- PE安装原版XP系统(含高版本PE安装选项灰色处理办法)
PE 安装 XP 镜像流程准备原版 XP 安装光盘镜像放到硬盘非 C 盘. 可解压到本地经行安装, 也可以使用虚拟光驱载入安装 (本教程主要讲 PE 内虚拟光驱载入安装) 第一步:用 U 盘或硬盘/光 ...
- 安装sass时,gem在国内不能安装的解决
最近在安装SASS的时候,用到gem命令,但是运行出行如下错误!(先声明,安装sass前,要保证自己电脑安装了ruby:ruby -v可以测试下有没有装) 原因是ruby 的gem被和谐了,现在淘宝的 ...
随机推荐
- Java | 基础归纳 | Map.Entry<String, String>
public class Test { private static Map<String,String> student; private static void init() { st ...
- JSP && Servlet | 上传文件
在WebContent下新建index.jsp 要点: 1. 表单 method 属性应该设置为 POST 方法,不能使用 GET 方法. 2. 表单 enctype 属性应该设置为 multip ...
- BZOJ1415(期望dp)
解法: 首先bfs预处理go数组:可可在j点时聪聪在点i是怎样贪心走的,这是为了之后O(1)获取转移线路. 然后dfs记忆化一下f[i][j],代表从i到j的期望,对于每层:将所有情况的期望值相加.边 ...
- 【aspnetcore】让aspnetcore支持less文件
第一步:新建文件 CustomerFileExtensionContentTypeProvider namespace xxx { public class CustomerFileExtension ...
- this详解,对执行上下文说 Yes
this 指向多变,很多隐蔽的 bug 都缘于它.与此同时,this 强大灵活,如果能熟练驾驭,就会写出更简洁.优雅的代码. 社区上对于 this 的讲解虽然不少,但缺乏统一梳理. this 相关知识 ...
- AngularJs数据绑定原理
注 这篇博文主要是写给新手的,是给那些刚刚开始接触Angular,并且想了解数据帮定是如何工作的人.如果你已经对Angular比较了解了,那强烈建议你直接去阅读源代码. Angular用户都想知道数据 ...
- XML文件的解析和序列化
序列化: private void createXml() { XmlSerializer serializer = Xml.newSerializer();// xml文件生成器 File file ...
- 基于eclipse搭建android开发环境-win7 32bit
基于eclipse搭建android开发环境-win7 32bit 前言:在使用朋友已搭建的Android开发环境时,发现朋友的开发环境版本较低且在update SDk时失败,便决定根据网上文章提示从 ...
- Perl 输出内容到 excel
可以参考: http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm 使用Spre ...
- Assertion failure layoutSublayersOfLayer:], /SourceCache
现象:代码在simulator上能够正常运行但是在真机上出现 Assertion failure in -[UIView layoutSublayersOfLayer:], /SourceCache/ ...