mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
new parameters of search()
This commit is contained in:
parent
364612f497
commit
c93faff257
|
@ -59,30 +59,42 @@ class SeedDMS_Lucene_Search {
|
|||
* @param object $index lucene index
|
||||
* @return object instance of SeedDMS_Lucene_Search
|
||||
*/
|
||||
function search($term, $owner, $status='', $categories=array(), $fields=array(), $users=array()) { /* {{{ */
|
||||
function search($term, $fields=array()) { /* {{{ */
|
||||
$querystr = '';
|
||||
if($fields) {
|
||||
} else {
|
||||
if($term)
|
||||
$querystr .= trim($term);
|
||||
if($term)
|
||||
$querystr .= trim($term);
|
||||
if(isset($fields['owner'])) {
|
||||
if(is_string($owner)) {
|
||||
if($querystr)
|
||||
$querystr .= ' && ';
|
||||
$querystr .= 'owner:'.$owner;
|
||||
} elseif(is_array($fields['owner'])) {
|
||||
if($querystr)
|
||||
$querystr .= ' && ';
|
||||
$querystr .= '(owner:"';
|
||||
$querystr .= implode('" || owner:"', $fields['owner']);
|
||||
$querystr .= '")';
|
||||
}
|
||||
}
|
||||
if($owner) {
|
||||
if($querystr)
|
||||
$querystr .= ' && ';
|
||||
$querystr .= 'owner:'.$owner;
|
||||
}
|
||||
if($categories) {
|
||||
if(isset($fields['category'])) {
|
||||
if($querystr)
|
||||
$querystr .= ' && ';
|
||||
$querystr .= '(category:"';
|
||||
$querystr .= implode('" || category:"', $categories);
|
||||
$querystr .= implode('" || category:"', $fields['category']);
|
||||
$querystr .= '")';
|
||||
}
|
||||
if($users) {
|
||||
if(isset($fields['status'])) {
|
||||
if($querystr)
|
||||
$querystr .= ' && ';
|
||||
$querystr .= '(status:"';
|
||||
$querystr .= implode('" || status:"', $fields['status']);
|
||||
$querystr .= '")';
|
||||
}
|
||||
if(isset($fields['user'])) {
|
||||
if($querystr)
|
||||
$querystr .= ' && ';
|
||||
$querystr .= '(users:"';
|
||||
$querystr .= implode('" || users:"', $users);
|
||||
$querystr .= implode('" || users:"', $fields['user']);
|
||||
$querystr .= '")';
|
||||
}
|
||||
try {
|
||||
|
@ -93,7 +105,7 @@ class SeedDMS_Lucene_Search {
|
|||
foreach($hits as $hit) {
|
||||
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->document_id);
|
||||
}
|
||||
return array('count'=>count($hits), 'hits'=>$recs);
|
||||
return array('count'=>count($hits), 'hits'=>$recs, 'facets'=>array());
|
||||
} catch (Zend_Search_Lucene_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -59,35 +59,44 @@ class SeedDMS_SQliteFTS_Search {
|
|||
* @param object $index SQlite FTS index
|
||||
* @return object instance of SeedDMS_Lucene_Search
|
||||
*/
|
||||
function search($term, $owner, $status='', $categories=array(), $fields=array(), $users=array()) { /* {{{ */
|
||||
function search($term, $fields=array()) { /* {{{ */
|
||||
$querystr = '';
|
||||
if($fields) {
|
||||
} else {
|
||||
if($term)
|
||||
$querystr .= trim($term);
|
||||
if($term)
|
||||
$querystr .= trim($term);
|
||||
if(isset($fields['owner'])) {
|
||||
if(is_string($fields['owner'])) {
|
||||
if($querystr)
|
||||
$querystr .= ' ';
|
||||
$querystr .= 'owner:'.$fields['owner'];
|
||||
} elseif(is_array($fields['owner'])) {
|
||||
if($querystr)
|
||||
$querystr .= ' ';
|
||||
$querystr .= '(owner:';
|
||||
$querystr .= implode(' OR owner:', $fields['owner']);
|
||||
$querystr .= ')';
|
||||
}
|
||||
}
|
||||
if($owner) {
|
||||
if(isset($fields['category'])) {
|
||||
if($querystr)
|
||||
$querystr .= ' ';
|
||||
//$querystr .= ' AND ';
|
||||
$querystr .= 'owner:'.$owner;
|
||||
//$querystr .= $owner;
|
||||
$querystr .= '(category:';
|
||||
$querystr .= implode(' OR category:', $fields['category']);
|
||||
$querystr .= ')';
|
||||
}
|
||||
if($categories) {
|
||||
if(isset($fields['status'])) {
|
||||
if($querystr)
|
||||
$querystr .= ' ';
|
||||
//$querystr .= ' AND ';
|
||||
$querystr .= 'category:';
|
||||
$querystr .= implode(' OR category:', $categories);
|
||||
$querystr .= '';
|
||||
$status = array_map(function($v){return $v+10;}, $fields['status']);
|
||||
$querystr .= '(status:';
|
||||
$querystr .= implode(' OR status:', $status);
|
||||
$querystr .= ')';
|
||||
}
|
||||
if($users) {
|
||||
if(isset($fields['user'])) {
|
||||
if($querystr)
|
||||
$querystr .= ' ';
|
||||
//$querystr .= ' AND ';
|
||||
$querystr .= 'users:';
|
||||
$querystr .= implode(' OR users:', $users);
|
||||
$querystr .= '';
|
||||
$querystr .= '(users:';
|
||||
$querystr .= implode(' OR users:', $fields['user']);
|
||||
$querystr .= ')';
|
||||
}
|
||||
try {
|
||||
$result = $this->index->find($querystr);
|
||||
|
@ -95,7 +104,7 @@ class SeedDMS_SQliteFTS_Search {
|
|||
foreach($result["hits"] as $hit) {
|
||||
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->id);
|
||||
}
|
||||
return array('count'=>$result['count'], 'hits'=>$recs);
|
||||
return array('count'=>$result['count'], 'hits'=>$recs, 'facets'=>array());
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user