xunsearch是用还是很方便的,在此我分享一个封装好的类,方便需要的人。
XunSearch的使用教程:
github地址:https://github.com/ziyueit/xunsearch/blob/master/XunSearch.php
实例化对象:
include 'XunSearch.php'; $xun = new XunSearch('blog');
方法列表:
search 搜索操作
addIndex 将文档添加到索引中
flushIndex 强制更新当前索引库的索引缓存
clearIndex 清空当前索引库的所有索引
delete 讲一个文档从索引库中删除
hotWord 获取搜索热词
expanded 获取相关词
lastCount 获取最近一次搜索的结果匹配总数估算值
addSynonym 添加一对同义词
flushLog 强制刷新服务端当前项目的搜索日志
基于这个类写的一个xunsearch使用的小例子
github地址:https://github.com/ziyueit/xunsearch
目录说明:
www WEB部署目录
├─php xunsearch-1.4.9 安装后的sdk
├─README.md README文件
├─PDO.php King老师写的一个PDO操作类
├─XunSearch.php 迅搜封装类
├─add.html 添加数据的表单
├─add.php 添加数据和索引操作
├─clear.php 清除索引操作
├─search.php 搜索操作演示
└─test.sql 测试用的表结构
关于迅搜的安装和使用中遇到的问题可以参阅: