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


PHP Indexer::filterQuery方法代碼示例

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


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

示例1: buildQuery

    /**
     * Build a Lucene Query.
     * 
     * @param  array   $data      - The data (normally $_POST), needs specific array keys
     * @param  boolean $anonymous - whether we build query for anonymous user access or not
     * @return string             - the returned query string
     */
    public static function buildQuery($data, $anonymous = true) {
        if (isset($data['search_terms']) && !empty($data['search_terms']) &&
                isset($data['course_id']) && !empty($data['course_id'])) {
            $terms = explode(' ', Indexer::filterQuery($data['search_terms']));
            $queryStr = '(';
            foreach ($terms as $term) {
                $queryStr .= 'title:' . $term . '* ';
                $queryStr .= 'content:' . $term . '* ';
                $queryStr .= 'filename:' . $term . '* ';
                $queryStr .= 'comment:' . $term . '* ';
                $queryStr .= 'creator:' . $term . '* ';
                $queryStr .= 'subject:' . $term . '* ';
                $queryStr .= 'author:' . $term . '* ';
            }
            $queryStr .= ') AND courseid:' . $data['course_id'] . ' AND doctype:doc AND visible:1';
            if ($anonymous) {
                $queryStr .= ' AND public:1';
            }
            return $queryStr;
        }

        return null;
    }
開發者ID:nikosv,項目名稱:openeclass,代碼行數:30,代碼來源:documentindexer.class.php

示例2: buildQuery

    /**
     * Build a Lucene Query.
     * 
     * @param  array   $data      - The data (normally $_POST), needs specific array keys
     * @param  boolean $anonymous - whether we build query for anonymous user access or not
     * @return string             - the returned query string
     */
    public static function buildQuery($data, $anonymous = true) {
        if (isset($data['search_terms']) && !empty($data['search_terms']) &&
                isset($data['course_id']) && !empty($data['course_id'])) {
            $terms = explode(' ', Indexer::filterQuery($data['search_terms']));
            $queryStr = '(';
            foreach ($terms as $term) {
                $queryStr .= 'title:' . $term . '* ';
            }
            $queryStr .= ') AND courseid:' . $data['course_id'] . ' AND doctype:ftopic';
            return $queryStr;
        }

        return null;
    }
開發者ID:nikosv,項目名稱:openeclass,代碼行數:21,代碼來源:forumtopicindexer.class.php

示例3: appendQuery

 /**
  * Append to the Lucene Query according to data input.
  * 
  * @param  array   $data     - The data (normally coming from $_POST)
  * @param  string  $key      - $data[key]
  * @param  string  $queryKey - Lucene Document field key
  * @param  string  $queryStr - The Lucene Query string
  * @param  boolean $needsOR  - special flag for appending OR
  * @return array             - returns the Lucene Query string and the flag for appending OR in an array
  */
 private static function appendQuery($data, $key, $queryKey, $queryStr, $needsOR) {
     if (isset($data[$key]) && !empty($data[$key])) {
         $terms = explode(' ', Indexer::filterQuery($data[$key]));
         foreach ($terms as $term) {
             $queryStr .= ($needsOR) ? 'OR ' : '';
             $queryStr .= $queryKey . ':' . $term . '* ';
             $needsOR = true;
         }
     }
     return array($queryStr, $needsOR);
 }
開發者ID:nikosv,項目名稱:openeclass,代碼行數:21,代碼來源:courseindexer.class.php


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