コード例 #1
0
ファイル: places.php プロジェクト: s-a-r-id/geograph-project
if (!empty($_GET['q'])) {
    $q = trim($_GET['q']);
    $fuzzy = !empty($_GET['f']);
    $sphinx = new sphinxwrapper($q);
    //gets a cleaned up verion of the query (suitable for filename etc)
    $cacheid = $sphinx->q . '.' . $fuzzy;
    $sphinx->pageSize = $pgsize = 15;
    $pg = !empty($_GET['page']) ? intval(str_replace('/', '', $_GET['page'])) : 0;
    if (empty($pg) || $pg < 1) {
        $pg = 1;
    }
    $cacheid .= "." . $pg;
    if (!$smarty->is_cached($template, $cacheid)) {
        $offset = ($pg - 1) * $sphinx->pageSize + 1;
        if ($offset < 1000 - $pgsize) {
            $sphinx->processQuery();
            $sphinx->sort = "score ASC, @relevance DESC, @id DESC";
            #$sphinx->sort = -1;
            #$sphinx->_getClient()->SetSortMode(SPH_SORT_EXPR,"(10-score) * @weight");
            #			if (preg_match('/^\w+$/',$sphinx->q)) {
            #				$sphinx->qoutput = $sphinx->q;
            #				$sphinx->q = "{$sphinx->q} | {$sphinx->q}*"; //rank full matches first
            #			}
            if ($fuzzy) {
                $sphinx->_getClient()->SetIndexWeights(array('gaz' => 10, 'gaz_meta' => 1));
                $ids = $sphinx->returnIds($pg, 'gaz,gaz_meta');
            } else {
                $ids = $sphinx->returnIds($pg, 'gaz');
            }
            if (!empty($ids) && count($ids)) {
                $where = "id IN(" . join(",", $ids) . ")";
コード例 #2
0
 /**
  * get image list for particular query
  */
 function getImagesBySphinx($q, $pgsize = 15, $pg = 1)
 {
     $sphinx = new sphinxwrapper($q);
     $sphinx->pageSize = $pgsize;
     $sphinx->processQuery();
     $ids = $sphinx->returnIds($pg, '_images');
     if (count($ids)) {
         $this->resultCount = $sphinx->resultCount;
         return $this->getImagesByIdList($ids);
     } else {
         return 0;
     }
 }