基于 XunSearch(迅搜)SDK 的全文搜索 Laravel 5.* 软件包,支持全拼、拼音简写、模糊搜索、热门搜索、搜索提示

由 Ming 创建于2年前, 最后更新于 1年前

版本号 #1

6143 views

5 likes

0 collects

xunsearch-laravel

前置说明:

请先安装xunsearch 服务端:

普通编译安装(推荐)wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2

tar -xjf xunsearch-full-latest.tar.bz2

cd xunsearch-full-1.4.11/ //下载的版本文件夹

sh setup.sh

//第一次安装的话,过程可能会稍显漫长,请不必着急,您大可泡杯茶一边喝一边等待即可。

cd $prefix ; bin/xs-ctl.sh restart

更多详情请移步:http://www.xunsearch.com/doc/php/guide/start.installation

docker 安装Docker 方式安装服务端

//下载映像:

docker pull hightman/xunsearch

//启动映像:

docker run --name xunsearch -d \

-p 8383:8383 -p 8384:8384 \

-v /var/xunsearch/data:/usr/local/xunsearch/data \

hightman/xunsearch:latest

//以上启动参数可自行修改,该方式仅运行服务端

Installing

$ composer require shaozeming/xunsearch-laravel -v

Laravel

// config/app.php

'providers' => [

//...

ShaoZeMing\Laravelxunsearch\XunsearchServiceProvider::class, //This is default in laravel 5.5

],

And publish the config file:

$ php artisan vendor:publish --provider=ShaoZeMing\\LaravelXunsearch\\XunsearchServiceProvider

if you want to use facade mode, you can register a facade name what you want to use, for example xunsearch:

// config/app.php

'aliases' => [

'xunsearch' => ShaoZeMing\LaravelXunsearch\Facade\Xunsearch::class, //This is default in laravel 5.5

],

lumen

在 bootstrap/app.php 中 82 行左右:

$app->register( ShaoZeMing\LaravelXunsearch\xunsearchServiceProvider::class);

将 vendor/ShaoZeMing/laravel-xunsearch/config/xunsearch.php 拷贝到项目根目录/config目录下,并将文件名改成xunsearch.php。

configuration

老师搜索库配置 配置结构和官方ini文件类似,只不过替换为了php 数组形式方式展示,请照着官方文档和本配置文件对比,葫芦画瓢:http://www.xunsearch.com/doc/php/guide/ini.guide// config/xunsearch.php

'default' => 'teacher', //默认搜索库

'databases' => [

// 老师搜索库配置 配置结构和官方ini文件类似,只不过替换为了php 数组形式方式展示,请照着官方文档和本配置文件对比,葫芦画瓢:http://www.xunsearch.com/doc/php/guide/ini.guide

'teacher' => [

'project.name' => 'teacher',

'project.default_charset' => 'utf-8',

'server.index' => '127.0.0.1:8383',

'server.search' => '127.0.0.1:8384',

'id' => [

'type' => 'id',

],

'email' => [

'index' => 'mixed',

],

'name' => [

'index' => 'mixed',

],

'desc' => [

'index' => 'mixed',

],

],

//学生搜索库

'student' => [

'project.name' => 'student',

'project.default_charset' => 'utf-8',

'server.index' => '127.0.0.1:8383',

'server.search' => '127.0.0.1:8384',

'id' => [

'type' => 'id',

],

'email' => [

'index' => 'mixed',

],

'name' => [

'index' => 'mixed',

],

'desc' => [

'index' => 'mixed',

],

],

// ... 更多

],

Example:

use ShaoZeMing\LaravelXunsearch\Facade\Xunsearch;

$data =[

['id' => 1, 'email' => '928240096@qq.com', 'name' => 'Shao ZeMing 邵泽明 邵澤明', 'lesson' => '朗诵主持,Reciting Hosting,朗誦主持,','desc'=>'我是谁,我在哪儿,我要做什么,我不告诉你'],

['id' => 2, 'email' => '12315@qq.com', 'name' => 'Chris Dong 董胜君 董勝君', 'lesson' => '朗诵主持,Reciting Hosting,朗誦主持,演講辯論,speech debate,演讲辩论','desc'=>'如果有一天,我走了,你应该知道我去了哪儿'],

['id' => 3, 'email' => 'shao-ze-ming@outlook.com', 'name' => '二傻子 Two fools', 'lesson' => '朗诵主持,Reciting Hosting,朗誦主持,','desc'=>'最近头发掉的厉害,我该怎么办好呀'],

['id' => 4, 'email' => 'szm19920426@qq.com', 'name' => '君莫笑 jun mo xiao 君莫笑', 'lesson' => '写作批改,writing correction,寫作批改,国学经典,National Classics,國學經典','desc'=>'哎呀,脑壳疼,脑壳疼,脑壳疼'],

['id' => 5, 'email' => '1270912585@qq.com', 'name' => '李四,li si 李四', 'lesson' => '朗诵主持,Reciting Hosting,朗誦主持,演講辯論,speech debate,演讲辩论,国学经典,National Classics,國學經典','desc'=>'你知道我对你不静静是喜欢'],

];

// Xunsearch::addIndex($data); //添加索引

// Xunsearch::setDatabase('student')->addIndex($data); //添加自定义索引数据库索引

// $data = ['id'=>1,'email'=>'123456@ming.com'];

// Xunsearch::updateIndexOne($data); 更新索引

// Xunsearch::setDatabase('student')->updateIndexOne($data); 更新自定义索引数据库索引

// Xunsearch::delIndex($ids); 删除索引

// Xunsearch::setDatabase('student')->delIndex($ids); 删除自定义索引数据库索引

// Xunsearch::cleanIndex(); 清空索引

// Xunsearch::setDatabase('student')->cleanIndex(); 清空自定义索引数据库索引

// $res = Xunsearch::search('朗诵'); //默认搜索

// $res = Xunsearch::setLimit(15)->search('朗诵'); //搜索每页条数

// $res = Xunsearch::setSort('id',true)->setLimit(15)->search('朗诵'); //搜索排序

$res = Xunsearch::setDatabase('student')->setLimit(15)->search('朗诵'); //设置索引数据库

print_r($res);

* @return array 返回数组结构

return [

'doc' => Object, //搜索数据结果文档

'hot' => array, //热门词汇

'count' => int, //搜索结果统计

'total' => int, //数据库总数据

'corrected' => array, //搜索提示

'related' => array, //相关搜索

'search_cost' => float, //搜索所用时间

'total_cost' => float, //页面所用时间

];

*/

/*

示例结果:

Array

(

[doc] => Array

(

[0] => XSDocument Object

(

[_data:XSDocument:private] => Array

(

[id] => 1

[email] => 928240096@qq.com

[name] => Shao ZeMing 邵泽明 邵澤明

[lesson] => 朗诵主持,Reciting Hosting,朗誦主持,

[desc] => 我是谁,我在哪儿,我要做什么,我不告诉你

[255] =>

)

[_terms:XSDocument:private] =>

[_texts:XSDocument:private] =>

[_charset:XSDocument:private] => UTF-8

[_meta:XSDocument:private] => Array

(

[docid] => 1

[rank] => 1

[ccount] => 0

[percent] => 100

[weight] => 1.1440536975861

)

)

)

[hot] => Array

(

)

[count] => 1

[total] => 5

[corrected] => Array

(

)

[related] => Array

(

)

[search_cost] => 0.00080204010009766

[total_cost] => 0.004767894744873

)

*/

License

MIT

拼音模糊搜索 php,基于 XunSearch(迅搜)SDK 的全文搜索 Laravel 5.* 软件包,支持全拼、拼音简写、模糊搜索、热门搜索、搜索提示...相关推荐

  1. 讯搜 配置mysql_实例讲解帝国cms整合xunsearch(迅搜)教程

    实例讲解帝国cms整合xunsearch(迅搜)教程 来源:51酷酷 编辑:广告联盟评测网 时间:2017-11-28 16:50:18 帝国CMS安装迅搜_linux系统下 安装迅搜记录 目的:由于 ...

  2. xunsearch(迅搜中文全文搜索引擎)的简单使用

    Xunsearch (中文名:迅搜)是一套免费开源的专业中文全文检索解决方案,简单易用而且 功能强大.性能卓越能轻松处理海量数据的全文检索.它包含后端索引.搜索服务程序和前端 脚本语言编写的开发工具包 ...

  3. python缩写转换成全拼_Python中文转拼音代码(支持全拼和首字母缩写)

    #!/usr/bin/env python # -*- coding:utf-8 -*- """ 原版代码:https://github.com/cleverdeng/p ...

  4. oracle汉字转拼音(获得全拼/拼音首字母/拼音截取等)

    oracle汉字转拼音(获得全拼/拼音首字母/拼音截取等) oracle 字符集 GBK 没有问题 , UTF -8 需要修改一下 1.获得全拼 SELECT GETHZPY.GETHZFULLPY( ...

  5. xunsearch 迅搜初探

    2014年1月2日 19:34:12 1 [root@localhost bin]# ./php /usr/local/lamp/xunsearch/sdk/php/util/Quest.php de ...

  6. xunsearch php,GitHub - ziyueit/xunsearch: 迅搜的一个PHP封装类

    xunsearch xunsearch的一个PHP封装类 目录结构说明 www  WEB部署目录 ├─php                                xunsearch-1.4. ...

  7. Xunsearch迅搜项目实战经验

    在这里我们使用的是SDK以及一台xunsearch服务器,意思是不在同一服务器上的.xunsearch服务器和sdk服务器. 1.部署xunsearch服务器,网上还是有文档的 第一步  下载解压 w ...

  8. 迅搜 php,XunSearch(迅搜) | 搜索

    1.安装篇 运行下面指令下载.解压安装包 wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2 tar -xjf x ...

  9. 333lu.vip.php,PHP实现汉字自动转全拼拼音

    /** * 基于PHP语言的汉语转拼音的类 * 兼容 UTF8.GBK.GB2312 编码,无须特殊处理 * 对中文默认返回拼音首字母缩写,其它字符不作处理直接返回. */ class Pinyin{ ...

  10. ES支持中文全拼拼音首字母搜索

    环境 Ubuntu18.04 ES 6.6.1 搜索模板 新建模板,便于后续创建索引,直接使用模板,省事方便 PUT _template/goods {"index_patterns&quo ...

最新文章

  1. 样条+样条函数+样条分析+spline+样条插值+样条回归
  2. OLEDB访问CSV、txt
  3. linux tomcat端口无法,linux下tomcat无法远程访问(开放8080端口)
  4. RESTful API 中的 Status code 是否要遵守规范
  5. 新人问一般都用哪些 Linux 命令,我把这个扔了过去
  6. Ubuntu14.04下搭建Bochs仿真平台,同时用该平台安装Linux0.11内核
  7. 【数据结构与算法】广度优先遍历(BFS) 深度优先遍历(DFS)
  8. 【华为云技术分享】Entity Framework Core 捕获数据库变动
  9. 关于C语言可变参数函数的一些研究和总结
  10. 四种引用类型:强、软、弱、虚
  11. Aggregated Residual Transformations for DeepNeural Networks -ResNetXt2017【论文理解】
  12. 药店收费系统服务器,智能药店收费管理系统
  13. vue点击图片放大功能
  14. Android游戏引擎汇总,架构师花费近一年时间整理出来的安卓核心知识
  15. 计算机各键的名称和作用,space是什么键 键盘键位名称及功用详解
  16. android自动化测试辅助工具Weinre
  17. HTML+CSS基础学习
  18. centos7安装docker以及部署centos7:lastest
  19. 7-15 铁路托运行李费用 (10分)
  20. DNN摸索系列1:DNN 6 如何添加新皮肤包

热门文章

  1. 全国大部分城市的经纬度位置
  2. 与计算机相关的统计表格,统计信息化 Excel与SPSS应用pdf
  3. 锐起无盘服务器需要什么配置,锐起无盘pnp硬件配置的实现
  4. RecSys2020推荐系统论文Recommending the Video to Watch Next: An Offline and Online Evaluation at YOUTV.de
  5. DELL官方证实:NVIDIA史上最大显卡质量事故
  6. 想让“贾维斯”成为现实?物联网帮你拥有
  7. 数字图像处理 冈萨雷斯(第四版)图像集合运算定义
  8. 机器学习实战+源代码
  9. 最全最新cpu显卡天梯图_2018 年新近详细CPU、显卡天梯图
  10. 大数据中心大数据资源平台建设方案