当前位置:Gxlcms > 数据库问题 > php + mysql + sphinx 的全文检索(2)

php + mysql + sphinx 的全文检索(2)

时间:2021-07-01 10:21:17 帮助过:2人阅读

  1. 简单 使用php api 去查询 sphinx 的索引数据
    1. $sphinx = new SphinxClient(); 
                $sphinx->SetServer ( ‘localhost‘, 9312 ); //sphinx的主机名和端口          //设置返回结果集为php数组格式         $sphinx->SetArrayResult ( true );         //匹配结果的偏移量,参数的意义依次为:起始位置,返回结果条数,最大匹配条数         $sphinx->SetLimits(0, 20, 1000);         //最大搜索时间         $sphinx->SetMaxQueryTime(10);         //执行简单的搜索,这个搜索将会查询所有字段的信息,要查询指定的字段请继续看下文         $index = ‘test1‘; //索引源是配置文件中的 index 类,如果有多个索引源可使用,号隔开:‘email,diary‘ 或者使用‘*‘号代表全部索引源         $result = $sphinx->query (‘doc‘, $index);         echo ‘<pre>‘;         print_r($result);         echo ‘</pre>‘; 

php + mysql + sphinx 的全文检索(2)

标签:

人气教程排行