本文整理匯總了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);
}