Skip to content

Commit 9b9c671

Browse files
committed
TASK: Implement ES5 FilteredQuery
1 parent 5934f90 commit 9b9c671

2 files changed

Lines changed: 55 additions & 2 deletions

File tree

Classes/Driver/Version5/Query/FilteredQuery.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,37 @@
1212
*/
1313

1414
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\Version1;
15+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception;
1516

1617
/**
1718
* Default Filtered Query
1819
*/
1920
class FilteredQuery extends Version1\Query\FilteredQuery
2021
{
22+
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function fulltext($searchWord)
27+
{
28+
$this->appendAtPath('query.bool.must', [
29+
'query_string' => [
30+
'query' => $searchWord
31+
]
32+
]);
33+
}
34+
35+
/**
36+
* {@inheritdoc}
37+
*/
38+
public function queryFilter($filterType, $filterOptions, $clauseType = 'must')
39+
{
40+
if (!in_array($clauseType, ['must', 'should', 'must_not'])) {
41+
throw new Exception\QueryBuildingException('The given clause type "' . $clauseType . '" is not supported. Must be one of "must", "should", "must_not".',
42+
1383716082);
43+
}
44+
45+
$this->appendAtPath('query.bool.filter.bool.' . $clauseType, [$filterType => $filterOptions]);
46+
}
47+
2148
}

Configuration/Settings.yaml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,35 @@ Flowpack:
7979
className: 'Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\Version5\Query\FilteredQuery'
8080
arguments:
8181
request:
82-
<<: *request_version1
82+
query:
83+
bool:
84+
must:
85+
- match_all:
86+
boost: 1.0 # force match_all to be an object
87+
filter:
88+
bool:
89+
must: []
90+
should: []
91+
must_not:
92+
- term:
93+
_hidden: true
94+
- range:
95+
_hiddenBeforeDateTime:
96+
gt: now
97+
- range:
98+
_hiddenAfterDateTime:
99+
lt: now
100+
_source:
101+
- '__path'
83102
unsupportedFieldsInCountRequest:
84-
<<: *unsupportedFieldsInCountRequest_version1
103+
- '_source'
104+
- 'sort'
105+
- 'from'
106+
- 'size'
107+
- 'highlight'
108+
- 'aggs'
109+
- 'aggregations'
110+
- 'suggest'
85111
document:
86112
className: 'Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\Version5\DocumentDriver'
87113
indexer:

0 commit comments

Comments
 (0)