Skip to content

Commit cede5c5

Browse files
committed
[FEATURE] queryFilterMultiple operation for QueryBuilder
Usage:: searchFilter = TYPO3.TypoScript:RawArray { constraint1 = 'a' constraint2 = TYPO3.TypoScript:RawArray { 0 = 'b' 1 = 'c' } } searchQuery = ${Search.queryFilterMultiple(this.searchFilter)}
1 parent 46a2bbc commit cede5c5

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Eel/ElasticSearchQueryBuilder.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,26 @@ public function appendAtPath($path, array $data) {
329329
return $this;
330330
}
331331

332+
/**
333+
* Add multiple filters to query.filtered.filter
334+
*
335+
* @param array $data An associative array of keys as variable names and values as variable values
336+
* @param string $clauseType one of must, should, must_not
337+
* @return ElasticSearchQueryBuilder
338+
*/
339+
public function queryFilterMultiple($data, $clauseType = 'must') {
340+
foreach ($data as $key => $value) {
341+
if ($value !== NULL) {
342+
if (is_array($value)) {
343+
$this->queryFilter('terms', array($key => $value), $clauseType);
344+
} else {
345+
$this->queryFilter('term', array($key => $value), $clauseType);
346+
}
347+
}
348+
}
349+
return $this;
350+
}
351+
332352
/**
333353
* Get the ElasticSearch request as we need it
334354
*

0 commit comments

Comments
 (0)