]>
git.wh0rd.org - tt-rss.git/blob - plugins/search_sphinx/init.php
3 class Search_Sphinx
extends Plugin
{
6 "Delegate searching for articles to Sphinx",
11 function init($host) {
12 $host->add_hook($host::HOOK_SEARCH
, $this);
14 require_once __DIR__
. "/sphinxapi.php";
17 function hook_search($search) {
21 $sphinxClient = new SphinxClient();
23 $sphinxpair = explode(":", SPHINX_SERVER
, 2);
25 $sphinxClient->SetServer($sphinxpair[0], (int)$sphinxpair[1]);
26 $sphinxClient->SetConnectTimeout(1);
28 $sphinxClient->SetFieldWeights(array('title' => 70, 'content' => 30,
31 $sphinxClient->SetMatchMode(SPH_MATCH_EXTENDED2
);
32 $sphinxClient->SetRankingMode(SPH_RANK_PROXIMITY_BM25
);
33 $sphinxClient->SetLimits($offset, $limit, 1000);
34 $sphinxClient->SetArrayResult(false);
35 $sphinxClient->SetFilter('owner_uid', array($_SESSION['uid']));
37 $result = $sphinxClient->Query($search, SPHINX_INDEX
);
41 if (is_array($result['matches'])) {
42 foreach (array_keys($result['matches']) as $int_id) {
43 $ref_id = $result['matches'][$int_id]['attrs']['ref_id'];
44 array_push($ids, $ref_id);
48 $ids = join(",", $ids);
51 return array("ref_id IN ($ids)", array());
53 return array("ref_id = -1", array());
56 function api_version() {