安装与启动
http://www.xunsearch.com/doc/php/guide/start.installation
编写配置文件
http://www.xunsearch.com/doc/php/guide/ini.guide
http://www.xunsearch.com/doc/php/guide/ini.first
导入的数据需要与配置文件对应,注意索引字段,最好有一个both索引,后面测试都是self索引会导致不模糊查找没有数据
project.name = magicbox server.index = 192.168.1.168:8383 server.search = 192.168.1.168:8384 [id] type = id tokenizer = full [name] type = title index = both [platform] index = self tokenizer = full [class] index = self tokenizer = full [is_act] index = self tokenizer = full [is_avg] index = self tokenizer = full [is_mmorpg] index = self tokenizer = full [is_stg] index = self tokenizer = full [is_rpg] index = self tokenizer = full [is_mag] index = self tokenizer = full [is_spg] index = self tokenizer = full [is_rac] index = self tokenizer = full [is_mug] index = self tokenizer = full [is_puz] index = self tokenizer = full [is_tab] index = self tokenizer = full [is_td] index = self tokenizer = full [is_gsg] index = self tokenizer = full [is_etc] index = self tokenizer = full [type] index = self tokenizer = full [mark] [icon] [dl_url] [auth_status] index = self tokenizer = full [dl_count_px] type = numeric [dl_count] [star_px] type = numeric [star] [pub_time_px] type = numeric [pub_time] [comment_id]
导入数据使用sdk
php Indexer.php --rebuild --source=mysql://chaohaowan:123456@192.168.1.168/magicbox --sql="select *,UNIX_TIMESTAMP(pub_time) as pub_time_px,star as star_px,dl_count as dl_count_px from mb_resource" --project=magicbox
php Indexer.php --project=magicbox --info 查看数据导入与否
php Indexer.php --project=magicbox --flush 强制刷入数据
php Indexer.php --project=magicbox --clean 清空索引数据
以上就是建立索引的主要方法
查询
php Query.php --project=magicbox -q 测试
主要的api调用
http://www.xunsearch.com/doc/php/guide/search.query
$this -> search -> setAutoSynonyms(); //$this -> search -> setFuzzy(); //$wd = "$wd"; $this -> search -> setQuery($wd); //$this -> search -> setQuery('name:武士 僵尸 大战'); $this -> search -> addRange('auth_status',2,2); //header("Content-Type: text/html;Charset=UTF8;"); //$this -> search -> addRange('type',3,3); //$this -> search -> addRange('platform',2,2); //$this -> search -> setSort('dl_count_px',false); // $this -> search -> setLimit(3, 0); // $querty = $this -> search -> getQuery(); //$dataA = $this -> search -> search(); // //$count = $this -> search -> getLastCount(); // var_dump($querty); //$this -> search -> setSort('pub_time_px',false); // $querty = $this -> search -> getQuery(); //var_dump($dataA);exit;
更新索引数据,删除等
http://www.xunsearch.com/doc/php/guide/index.update
分词
http://www.xunsearch.com/doc/php/guide/special.scws