Coreseek:第三步调用api搜寻php版

WBOY
Release: 2016-06-13 11:58:14
Original
806 people have browsed it

Coreseek:第三步调用api搜索php版

有三个步骤

1.讲searchd进程写成一个服务,不然每次调用都要打开这个进程很麻烦。

g:\service\coreseek\bin\searchd --install --config g:/service/coreseek/etc/csft_mysql.conf --servicename Coreseek

同样的万变不离其宗还是跟配置文件有关系

一个参数是你searchd的路径 ,第二个固定是--install,第三个是指后面跟配置文件--config,第三个是配置文件路径 后面是定义服务名称,不写也行,默认是searchd。

2.赋值接口文件,将 api 目录下的php接口文件 sphnixapi.php 复制到网站根目录下,因为可以看源码,其实就是一个类

3.写文件调用sphnixapi.文件

<meta http-equiv="content-type" content="text/html;charset=utf-8"><title>coreseek中文全文搜索在php程序中的应用</title><h3><font color="blue">coreseek全文搜索在php程序中应用</font></h3>
Copy after login
输入搜索的关键词:

SetServer('localhost',9312);//连接9312端口 /* 设置匹配模式 SPH_MATCH_ANY:表示只要搜索拆词后,其中某个词,就匹配出来。如:搜索引擎,只要包含“搜索"或"引擎"其中一个词,就可以匹配 SPH_MATCH_ALL:完整匹配。如搜索“搜索引擎”,需要完整出现“搜索引擎”这个词,才能匹配 */ $sph->SetMatchMode(SPH_MATCH_ANY); $result = $sph->query($keyword,"person");//执行搜索操作。news 表示索引名。如果需要在 csft_mysql.conf里所有的索引里搜索,则用 * 代替 echo "
"; print_r($result);//返回值为数组,先打印出来看看}?>
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!