當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AppCore::getSphinxAPI方法代碼示例

本文整理匯總了PHP中Railpage\AppCore::getSphinxAPI方法的典型用法代碼示例。如果您正苦於以下問題:PHP AppCore::getSphinxAPI方法的具體用法?PHP AppCore::getSphinxAPI怎麽用?PHP AppCore::getSphinxAPI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Railpage\AppCore的用法示例。


在下文中一共展示了AppCore::getSphinxAPI方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPhotosFromSphinx

 /**
  * Get photos from the Sphinx search API within or adjacent to this place
  * @since Version 3.9.1
  * @param int $num
  * @return array
  */
 public function getPhotosFromSphinx($num = 10)
 {
     $Sphinx = AppCore::getSphinxAPI();
     $Sphinx->SetGeoAnchor("lat", "lon", deg2rad($this->lat), deg2rad($this->lon));
     $Sphinx->SetFilterRange("@geodist", 0, 5000);
     // 1km radius
     $Sphinx->SetSortMode(SPH_SORT_EXTENDED, '@geodist ASC');
     $result = $Sphinx->query("", "idx_images");
     $return = array("stat" => "ok");
     if (!$result) {
         $return['stat'] = "err";
         $return['message'] = $Sphinx->getLastError();
         return $return;
     }
     if (empty($result['matches'])) {
         return $return;
     }
     foreach ($result['matches'] as $row) {
         $meta = json_decode($row['attrs']['meta'], true);
         $return['photos'][] = array("id" => $row['attrs']['image_id'], "provider" => $row['attrs']['provider'], "photo_id" => $row['attrs']['photo_id'], "url" => $row['attrs']['url'], "distance" => round($row['attrs']['@geodist']), "lat" => rad2deg($row['attrs']['lat']), "lon" => rad2deg($row['attrs']['lon']), "title" => empty(trim($row['attrs']['title'])) ? "Untitled" : $row['attrs']['title'], "description" => $row['attrs']['description'], "sizes" => Images::normaliseSizes($meta['sizes']));
     }
     $return['photos'] = array_slice($return['photos'], 0, $num);
     return $return;
 }
開發者ID:railpage,項目名稱:railpagecore,代碼行數:30,代碼來源:Place.php

示例2: findCorrectArticle

 /**
  * Find articles with similar titles (good for 404 errors)
  * @since Version 3.9.1
  * @return array
  * @param string $lookup The text to search Sphinx for
  * @param int $num The maximum number of results to return
  */
 public static function findCorrectArticle($lookup = false, $num = 5)
 {
     $Sphinx = AppCore::getSphinxAPI();
     $Sphinx->setLimits(0, $num);
     $results = $Sphinx->query($Sphinx->escapeString($lookup), "idx_news_article");
     return isset($results['matches']) ? $results['matches'] : array();
 }
開發者ID:railpage,項目名稱:railpagecore,代碼行數:14,代碼來源:News.php

示例3: getRelatedArticles

 /**
  * Find related news articles
  * @since Version 3.9
  * @return array
  *
  * @param int $num The maximum number of results to return
  */
 public function getRelatedArticles($num = 5)
 {
     $SphinxQL = $this->getSphinx();
     $title = preg_replace("/[^[:alnum:][:space:]]/u", '', $this->title);
     $title = trim($title);
     $title = str_replace(" ", "|", $title);
     $query = $SphinxQL->select("*")->from("idx_news_article")->match(array("story_title", "story_paragraphs"), $title, true)->where("story_id", "!=", $this->id)->where("story_time_unix", "BETWEEN", array(strtotime("1 year ago", time()), time()))->limit($num)->option("ranker", "proximity_BM25");
     $matches = $query->execute();
     if (count($matches)) {
         return $matches;
     }
     return array();
     $Sphinx = AppCore::getSphinxAPI();
     $Sphinx->setFilter("topic_id", array($this->Topic->id));
     $Sphinx->setFilter("story_id", array($this->id), true);
     $Sphinx->setFilterRange("story_time_unix", strtotime("1 year ago"), time());
     $Sphinx->setLimits(0, $num);
     $results = $Sphinx->query($Sphinx->escapeString($this->title), "idx_news_article");
     return isset($results['matches']) ? $results['matches'] : array();
 }
開發者ID:railpage,項目名稱:railpagecore,代碼行數:27,代碼來源:Article.php


注:本文中的Railpage\AppCore::getSphinxAPI方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。