色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

PHP擴(kuò)展之針對(duì)搜索引擎的擴(kuò)展(二)—— Sphinx簡(jiǎn)介、安裝及使用

瀏覽:82日期:2022-09-15 18:09:53
一、簡(jiǎn)介及安裝

該擴(kuò)展提供了針對(duì)Sphinx搜索客戶端開(kāi)發(fā)庫(kù)的綁定. Sphinx是一個(gè)獨(dú)立的搜索引擎系統(tǒng),其目的是為其他相關(guān)程序和應(yīng)用提供快速的、規(guī)模可擴(kuò)展的全文搜索功能. Sphinx有著良好的設(shè)計(jì),可以很方便的與SQL數(shù)據(jù)庫(kù)結(jié)合,并使用腳本語(yǔ)言調(diào)用. Sphinx 以及 其客戶端庫(kù) 可以從?官方站點(diǎn)獲取,中文用戶也可以從Coreseek獲取支持中文的版本和服務(wù)。

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

安裝步驟請(qǐng)參考:Linux下編譯安裝Sphinx、中文分詞coreseek及PHP的sphinx擴(kuò)展

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

編譯安裝:

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

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

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 提供了面向?qū)ο蟮慕涌?/p>SphinxClient::addQuery?— Add query to multi-query batchSphinxClient::buildExcerpts?— Build text snippetsSphinxClient::buildKeywords?— Extract keywords from querySphinxClient::close?— 關(guān)閉先前打開(kāi)的持久連接SphinxClient::__construct?— Create a new SphinxClient objectSphinxClient::escapeString?— Escape special charactersSphinxClient::getLastError?— Get the last error messageSphinxClient::getLastWarning?— Get the last warningSphinxClient::open?— 建立到搜索服務(wù)端的持久連接SphinxClient::query?— 執(zhí)行搜索查詢SphinxClient::resetFilters?— Clear all filtersSphinxClient::resetGroupBy?— Clear all group-by settingsSphinxClient::runQueries?— Run a batch of search queriesSphinxClient::setArrayResult?— 控制搜索結(jié)果集的返回格式SphinxClient::setConnectTimeout?— Set connection timeoutSphinxClient::setFieldWeights?— Set field weightsSphinxClient::setFilter?— 增加整數(shù)值過(guò)濾器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?— 設(shè)置返回結(jié)果集偏移量和數(shù)目SphinxClient::setMatchMode?— 設(shè)置全文查詢的匹配模式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?— 設(shè)置searchd的主機(jī)名和TCP端口SphinxClient::setSortMode?— Set matches sorting modeSphinxClient::status?— Queries searchd statusSphinxClient::updateAttributes?— Update document attributes

標(biāo)簽: PHP
相關(guān)文章:
主站蜘蛛池模板: 亚洲视频在线观看 | 久草福利在线观看 | 国产精品成人自拍 | 国产美女作爱视频 | 久草在线视频新时代视频 | 日本三级成人中文字幕乱码 | 一级毛片免费观看视频 | 毛片com | 欧美片a| 毛片免费看看 | 欧美精品免费在线 | 欧美激情成人网 | 欧美日韩精品一区二区另类 | 欧美一区二区免费 | 国产欧美日韩中文久久 | 日韩欧美久久一区二区 | 亚洲一区免费看 | 国产成人综合欧美精品久久 | 亚洲精品欧美精品国产精品 | 韩国一级毛片 | 一区二区在线看 | 国产精品免费精品自在线观看 | 国产精品成人观看视频网站 | 国产视频高清在线观看 | 成人午夜免费在线观看 | 欧美日本韩国一区 | 成人在线免费观看视频 | 国产成人精品一区二区三在线观看 | 久久成人18 | 91久久久久久久 | 日本精品1在线区 | a级毛片免费观看在线播放 a级毛片免费看 | 亚洲看看 | 日本美女作爱 | 精品午夜久久网成年网 | 888米奇在线视频四色 | a一级爱做片免费 | 亚洲毛片视频 | 免费观看成年人视频 | 一级毛片一级毛片一级毛片 | 亚洲午夜久久 |