Fix search when narrowed to private fields only

This commit is contained in:
Mathieu Darse
2015-07-16 19:06:46 +02:00
parent 7a330d2ef6
commit 78ab5b31dc
4 changed files with 18 additions and 4 deletions

View File

@@ -86,12 +86,20 @@ class QueryHelper
* @param array $sub_query Clause query
* @return array Resulting query
*/
public static function applyBooleanClause(array $query, $type, array $clause)
public static function applyBooleanClause($query, $type, array $clause)
{
if (!in_array($type, ['must', 'should'])) {
throw new \InvalidArgumentException(sprintf('Type must be either "must" or "should", "%s" given', $type));
}
if ($query === null) {
return $clause;
}
if (!is_array($query)) {
throw new \InvalidArgumentException(sprintf('Query must be either an array or null, "%s" given', gettype($query)));
}
if (!isset($query['bool'])) {
// Wrap in a boolean query
$bool = [];