本文整理汇总了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;
}
示例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;
}
示例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);
}