mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 09:35:00 +00:00
new parameter $limit of method search()
This commit is contained in:
parent
d4c4de6284
commit
e14774110f
|
@ -59,7 +59,7 @@ class SeedDMS_Lucene_Search {
|
|||
* @param object $index lucene index
|
||||
* @return object instance of SeedDMS_Lucene_Search
|
||||
*/
|
||||
function search($term, $fields=array()) { /* {{{ */
|
||||
function search($term, $fields=array(), $limit=array()) { /* {{{ */
|
||||
$querystr = '';
|
||||
if($term)
|
||||
$querystr .= trim($term);
|
||||
|
@ -102,8 +102,11 @@ class SeedDMS_Lucene_Search {
|
|||
try {
|
||||
$hits = $this->index->find($query);
|
||||
$recs = array();
|
||||
$c = 0;
|
||||
foreach($hits as $hit) {
|
||||
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->document_id);
|
||||
if($c >= $limit['offset'] && ($c-$limit['offset'] < $limit))
|
||||
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->document_id);
|
||||
$c++;
|
||||
}
|
||||
return array('count'=>count($hits), 'hits'=>$recs, 'facets'=>array());
|
||||
} catch (Zend_Search_Lucene_Exception $e) {
|
||||
|
|
|
@ -59,7 +59,7 @@ class SeedDMS_SQliteFTS_Search {
|
|||
* @param object $index SQlite FTS index
|
||||
* @return object instance of SeedDMS_Lucene_Search
|
||||
*/
|
||||
function search($term, $fields=array()) { /* {{{ */
|
||||
function search($term, $fields=array(), $limit=array()) { /* {{{ */
|
||||
$querystr = '';
|
||||
if($term)
|
||||
$querystr .= trim($term);
|
||||
|
@ -99,7 +99,7 @@ class SeedDMS_SQliteFTS_Search {
|
|||
$querystr .= ')';
|
||||
}
|
||||
try {
|
||||
$result = $this->index->find($querystr);
|
||||
$result = $this->index->find($querystr, $limit);
|
||||
$recs = array();
|
||||
foreach($result["hits"] as $hit) {
|
||||
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->id);
|
||||
|
|
Loading…
Reference in New Issue
Block a user