Heim  >  Artikel  >  Backend-Entwicklung  >  Coreseek:第三步调用api搜寻php版

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

WBOY
WBOYOriginal
2016-06-13 11:58:14806Durchsuche

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>
输入搜索的关键词:

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);//返回值为数组,先打印出来看看}?>


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn