From ec35c4fa4ba616c4614bdedd6b800543b455bace Mon Sep 17 00:00:00 2001 From: kevin_fourie Date: Fri, 3 Oct 2008 12:35:15 +0000 Subject: [PATCH] Merged in... --- search2/indexing/indexerCore.inc.php | 6 +++--- search2/search/expr.inc.php | 22 ++++++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/search2/indexing/indexerCore.inc.php b/search2/indexing/indexerCore.inc.php index 18876a8..48d9a19 100755 --- a/search2/indexing/indexerCore.inc.php +++ b/search2/indexing/indexerCore.inc.php @@ -1069,13 +1069,13 @@ abstract class Indexer $docsInIndex = $index->getDocumentsInIndex(); // we are only interested in documents that are active - $sql = "SELECT count(*) as docsInQueue FROM index_files"; + $sql = "SELECT count(*) as docsInQueue FROM index_files i inner join documents d on i.document_id = d.id where d.status_id=1"; $docsInQueue = DBUtil::getOneResultKey($sql, 'docsInQueue'); - $sql = "SELECT count(*) as errorsInQueue FROM index_files where status_msg is not null or status_msg <> ''"; + $sql = "SELECT count(*) as errorsInQueue FROM index_files i inner join documents d on i.document_id = d.id where (i.status_msg is not null or i.status_msg <> '') and d.status_id=1"; $errorsInQueue = DBUtil::getOneResultKey($sql, 'errorsInQueue'); - $sql = "SELECT count(*) as docsInRepository FROM documents"; + $sql = "SELECT count(*) as docsInRepository FROM documents where status_id=1"; $docsInRepository = DBUtil::getOneResultKey($sql, 'docsInRepository'); if ($docsInRepository == 0) diff --git a/search2/search/expr.inc.php b/search2/search/expr.inc.php index 7ac63ff..f7bb1fc 100755 --- a/search2/search/expr.inc.php +++ b/search2/search/expr.inc.php @@ -1176,7 +1176,7 @@ class SQLQueryBuilder implements QueryBuilder if (count($this->metadata) + count($this->db) == 0) { // return empty result set - return 'select 1 from documents where false'; + return ''; } $sql = @@ -1361,13 +1361,14 @@ class SQLQueryBuilder implements QueryBuilder $this->exploreExprs($expr); $sql = $this->buildCoreSQL(); - - $expr = $this->buildCoreSQLExpr($expr); - if ($expr != 'false') + if (empty($sql)) { - $sql .= $expr; + return ''; } + $expr = $this->buildCoreSQLExpr($expr); + $sql .= $expr; + return $sql; } @@ -2142,8 +2143,12 @@ class OpExpr extends Expr $sql = $exprbuilder->buildSimpleQuery($op, $group); } - $results = array(); + if (empty($sql)) + { + return array(); + } + $results = array(); global $default; $default->log->debug("SEARCH SQL: $sql"); $rs = DBUtil::getResultArray($sql); @@ -2192,6 +2197,11 @@ class OpExpr extends Expr $query = $exprbuilder->buildSimpleQuery($op, $group); } + if (empty($query)) + { + return array(); + } + $indexer = Indexer::get(); global $default; $default->log->debug("SEARCH LUCENE: $query"); -- libgit2 0.21.4