summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Coevoet <stof@notk.org>2012-01-09 20:29:40 +0100
committerChristophe Coevoet <stof@notk.org>2012-01-09 20:29:40 +0100
commitf3103777a2e10a40f8b1ec98164959afc32315cc (patch)
tree6986edf6d1f2876120b6975f8277f6bfd24624c6
parent8a3128811a7b08e4069682eb389960fd985e1a4d (diff)
Fixed bugs with empty boolean queries
-rw-r--r--src/Riu/Search/Engine/BooleanEngine.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Riu/Search/Engine/BooleanEngine.php b/src/Riu/Search/Engine/BooleanEngine.php
index d970805..5d38d56 100644
--- a/src/Riu/Search/Engine/BooleanEngine.php
+++ b/src/Riu/Search/Engine/BooleanEngine.php
@@ -31,7 +31,7 @@ class BooleanEngine implements EngineInterface
if (!preg_match('/^[\+\- \w]*$/i', $query)) {
throw new InvalidQueryException('The query is invalid');
}
- $orClauses = explode(' ', $query);
+ $orClauses = array_filter(explode(' ', $query));
$results = array_map(array($this, 'handleAndQuery'), $orClauses);
$result = call_user_func_array('array_merge', $results);
@@ -68,6 +68,7 @@ class BooleanEngine implements EngineInterface
}
// Handle removal for not clauses
+ $notClauses = array_filter($notClauses);
if (!empty($notClauses)) {
if (null === $result) {
$result = array_flip($this->matcher->getDocumentIds());
@@ -83,6 +84,6 @@ class BooleanEngine implements EngineInterface
}
}
- return array_keys($result);
+ return array_keys((array) $result);
}
}