mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-09 04:56:06 +00:00
add parameter $filter to find()
This commit is contained in:
parent
a00883c100
commit
35e2f86dba
|
@ -179,15 +179,22 @@ class SeedDMS_SQLiteFTS_Indexer {
|
|||
* @return boolean false in case of an error, otherwise array with elements
|
||||
* 'count', 'hits', 'facets'. 'hits' is an array of SeedDMS_SQLiteFTS_QueryHit
|
||||
*/
|
||||
public function find($query, $limit=array(), $order=array()) { /* {{{ */
|
||||
public function find($query, $filter, $limit=array(), $order=array()) { /* {{{ */
|
||||
if(!$this->_conn)
|
||||
return false;
|
||||
|
||||
/* First count some records for facets */
|
||||
foreach(array('owner', 'mimetype', 'category') as $facetname) {
|
||||
$sql = "SELECT `".$facetname."`, count(*) AS `c` FROM `docs`";
|
||||
if($query)
|
||||
if($query) {
|
||||
$sql .= " WHERE docs MATCH ".$this->_conn->quote($query);
|
||||
}
|
||||
if($filter) {
|
||||
if($query)
|
||||
$sql .= " AND ".$filter;
|
||||
else
|
||||
$sql .= " WHERE ".$filter;
|
||||
}
|
||||
$res = $this->_conn->query($sql." GROUP BY `".$facetname."`");
|
||||
if(!$res)
|
||||
throw new SeedDMS_SQLiteFTS_Exception("Counting records in facet \"$facetname\" failed.");
|
||||
|
@ -219,6 +226,12 @@ class SeedDMS_SQLiteFTS_Indexer {
|
|||
$sql = "SELECT `record_type`, count(*) AS `c` FROM `docs`";
|
||||
if($query)
|
||||
$sql .= " WHERE docs MATCH ".$this->_conn->quote($query);
|
||||
if($filter) {
|
||||
if($query)
|
||||
$sql .= " AND ".$filter;
|
||||
else
|
||||
$sql .= " WHERE ".$filter;
|
||||
}
|
||||
$res = $this->_conn->query($sql." GROUP BY `record_type`");
|
||||
if(!$res)
|
||||
throw new SeedDMS_SQLiteFTS_Exception("Counting records in facet \"record_type\" failed.");
|
||||
|
@ -232,6 +245,12 @@ class SeedDMS_SQLiteFTS_Indexer {
|
|||
$sql = "SELECT ".$this->_rawid.", documentid FROM docs";
|
||||
if($query)
|
||||
$sql .= " WHERE docs MATCH ".$this->_conn->quote($query);
|
||||
if($filter) {
|
||||
if($query)
|
||||
$sql .= " AND ".$filter;
|
||||
else
|
||||
$sql .= " WHERE ".$filter;
|
||||
}
|
||||
if($this->_ftstype == 'fts5') {
|
||||
//$sql .= " ORDER BY rank";
|
||||
// boost documentid, record_type, title, comment, keywords, category, mimetype, origfilename, owner, content, created unindexed, users, status, path
|
||||
|
|
Loading…
Reference in New Issue
Block a user