xunsearch 的使用
更多请阅读官网文档:http://www.xunsearch.com/
sdk
composer require --prefer-dist hightman/xunsearch "*@beta"
安装后,可使用命令行工具
vendor/bin/xs help
在项目中,先创建一个.ini配置文件(配置说明见官网)
;搜索配置文件示例
project.name = dgyun
project.default_charset = utf-8
server.index = 127.0.0.1:8383
server.search = 127.0.0.1:8384
[id]
type = id
;默认index=both
[title]
type = title
cutlen = 40
;默认index=mixed
[description]
type = body
cutlen = 100
进行一个简单的测试
增
$this->index->setDb($this->db);
$doc = new \XSDocument();
$data = [
'id' => 1,
'title' => '测试title',
'description' => '测试description',
];
$doc->setFields($data);
$this->index->add($doc);
删
$this->xs->index->setDb($this->db)->del([1])
改
$data = [
'id' => 1,
'title' => '测试title ' . date("His"),
'description' => '测试description',
'some' => '这是什么?',
];
$doc = new \XSDocument();
$doc->setFields($data);
$this->xs->index->setDb($this->db)->update($doc);
查
$this->xs->search->setDb($this->db)->search('测试')