当前位置: 首页>>代码示例>>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;未经允许,请勿转载。