亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

PHP擴展之針對搜索引擎的擴展(二)—— Sphinx簡介、安裝及使用

瀏覽:73日期:2022-09-15 18:09:53
一、簡介及安裝

該擴展提供了針對Sphinx搜索客戶端開發庫的綁定. Sphinx是一個獨立的搜索引擎系統,其目的是為其他相關程序和應用提供快速的、規??蓴U展的全文搜索功能. Sphinx有著良好的設計,可以很方便的與SQL數據庫結合,并使用腳本語言調用. Sphinx 以及 其客戶端庫 可以從?官方站點獲取,中文用戶也可以從Coreseek獲取支持中文的版本和服務。

安裝需求:需要PHP5.2.2及以上PHP版本。

安裝步驟請參考:Linux下編譯安裝Sphinx、中文分詞coreseek及PHP的sphinx擴展

安裝過程中,如果?./configure?不能正確找到 libsphinxclient 文件 (例如, 他被安裝在用戶自己定義的目錄中),使用?./configure --with-sphinx=$PREFIX來制定libsphinxclient的具體位置($PREFIX是libsphinxclient的安裝位置)。

編譯安裝:

從http://pecl.php.net/package/sphinx下載所需的sphinx擴展源碼安裝包,解壓到指定目錄,進入該目錄。

./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/libsphinxclientmakesudo make install二、使用實例

Example #1 基本使用范例

<?php$s = new SphinxClient;$s->setServer('localhost', 6712);$s->setMatchMode(SPH_MATCH_ANY);$s->setMaxQueryTime(3);$result = $s->query('test');var_dump($result);?>

以上例程的輸出類似于:

array(10) { ['error']=> string(0) '' ['warning']=> string(0) '' ['status']=> int(0) ['fields']=> array(3) {[0]=> string(7) 'subject'[1]=> string(4) 'body'[2]=> string(6) 'author' } ['attrs']=> array(0) {} ['matches']=> array(1) {[3]=> array(2) { ['weight']=> int(1) ['attrs']=> array(0) {} } } ['total']=> int(1) ['total_found']=> int(1) ['time']=> float(0) ['words']=> array(1) { ['to']=> array(2) { ['docs']=>int(1) ['hits']=>int(1) } }}三、SphinxClient 類

SphinxClient 為 Sphinx 提供了面向對象的接口

SphinxClient::addQuery?— Add query to multi-query batchSphinxClient::buildExcerpts?— Build text snippetsSphinxClient::buildKeywords?— Extract keywords from querySphinxClient::close?— 關閉先前打開的持久連接SphinxClient::__construct?— Create a new SphinxClient objectSphinxClient::escapeString?— Escape special charactersSphinxClient::getLastError?— Get the last error messageSphinxClient::getLastWarning?— Get the last warningSphinxClient::open?— 建立到搜索服務端的持久連接SphinxClient::query?— 執行搜索查詢SphinxClient::resetFilters?— Clear all filtersSphinxClient::resetGroupBy?— Clear all group-by settingsSphinxClient::runQueries?— Run a batch of search queriesSphinxClient::setArrayResult?— 控制搜索結果集的返回格式SphinxClient::setConnectTimeout?— Set connection timeoutSphinxClient::setFieldWeights?— Set field weightsSphinxClient::setFilter?— 增加整數值過濾器SphinxClient::setFilterFloatRange?— Add new float range filterSphinxClient::setFilterRange?— Add new integer range filterSphinxClient::setGeoAnchor?— Set anchor point for a geosphere distance calculationsSphinxClient::setGroupBy?— Set grouping attributeSphinxClient::setGroupDistinct?— Set attribute name for per-group distinct values count calculationsSphinxClient::setIDRange?— Set a range of accepted document IDsSphinxClient::setIndexWeights?— Set per-index weightsSphinxClient::setLimits?— 設置返回結果集偏移量和數目SphinxClient::setMatchMode?— 設置全文查詢的匹配模式SphinxClient::setMaxQueryTime?— Set maximum query timeSphinxClient::setOverride?— Sets temporary per-document attribute value overridesSphinxClient::setRankingMode?— Set ranking modeSphinxClient::setRetries?— Set retry count and delaySphinxClient::setSelect?— Set select clauseSphinxClient::setServer?— 設置searchd的主機名和TCP端口SphinxClient::setSortMode?— Set matches sorting modeSphinxClient::status?— Queries searchd statusSphinxClient::updateAttributes?— Update document attributes
標簽: PHP
相關文章:
主站蜘蛛池模板: 男女自偷自拍视频免费观看篇 | 91黑丝国产线观看免费 | 亚洲w码 | 播播网手机在线播放 | caob视频| 欧美一级毛片在线播放 | 无遮挡男女啪啪成人免费 | 一本久道久久综合 | 亚洲精品久久久久午夜 | pr社萌汁福利视频在线观看 | 免费香蕉依人在线视频久 | 欧美日韩中文在线视频 | 亚洲欧美自拍另类图片色 | 故意坐公交忘穿内裤被挺进小说 | 一区二区三区国产 | 欧美黄色片在线 | 成人影院欧美大片免费看 | 国产成人精品日本亚洲18图 | 欧美一级毛片高清视频 | 亚洲欧美在线综合一区二区三区 | 日本特黄特色大片免费视频观看 | 欧美久久伊人 | 精品视频在线观看你懂的一区 | 一级视频在线观看免费 | 99久久久国产精品免费牛牛四川 | 99久久精品自在自看国产 | 羞羞答答www网址进入在线观看 | 免费在线一级片 | 国产成 人 综合 亚洲绿色 | 久久久久草 | 国产精品原创巨作无遮挡 | 黄色中文字幕在线观看 | 亚洲国产高清精品线久久 | 亚洲人成网站在线在线 | 6699久久久久久久77777'7 66av99精品福利视频在线 | 欧美成人禁片在线观看俄罗斯 | 免费在线观看中文字幕 | 亚洲图片校园春色 | wwxxx日本| 免费观看欧美精品成人毛片能看的 | 国产精品亚洲欧美云霸高清 |