@@ 305-330 (lines=26) @@ | ||
302 | * |
|
303 | * @return BuilderInterface |
|
304 | */ |
|
305 | protected function addSubFilterAggregation( |
|
306 | $filterAggregation, |
|
307 | $deepLevelAggregation, |
|
308 | $terms, |
|
309 | $aggName |
|
310 | ) { |
|
311 | list($path, $field) = explode('>', $this->getField()); |
|
312 | $boolQuery = new BoolQuery(); |
|
313 | ||
314 | foreach ($terms as $term) { |
|
315 | $boolQuery->add( |
|
316 | new NestedQuery($path, new TermQuery($field, $term)) |
|
317 | ); |
|
318 | } |
|
319 | ||
320 | if ($boolQuery->getQueries() == []) { |
|
321 | $boolQuery->add(new MatchAllQuery()); |
|
322 | } |
|
323 | ||
324 | $innerFilterAggregation = new FilterAggregation( |
|
325 | $aggName, |
|
326 | $boolQuery |
|
327 | ); |
|
328 | $innerFilterAggregation->addAggregation($deepLevelAggregation); |
|
329 | $filterAggregation->addAggregation($innerFilterAggregation); |
|
330 | } |
|
331 | ||
332 | /** |
|
333 | * @param string $key |
@@ 116-141 (lines=26) @@ | ||
113 | * |
|
114 | * @return BuilderInterface |
|
115 | */ |
|
116 | protected function addSubFilterAggregation( |
|
117 | $filterAggregation, |
|
118 | $deepLevelAggregation, |
|
119 | $terms, |
|
120 | $aggName |
|
121 | ) { |
|
122 | list($path, $field) = explode('>', $this->getField()); |
|
123 | $boolQuery = new BoolQuery(); |
|
124 | ||
125 | foreach ($terms as $namedTerms) { |
|
126 | $boolQuery->add( |
|
127 | new NestedQuery($path, new TermsQuery($field, array_values($namedTerms))) |
|
128 | ); |
|
129 | } |
|
130 | ||
131 | if ($boolQuery->getQueries() == []) { |
|
132 | $boolQuery->add(new MatchAllQuery()); |
|
133 | } |
|
134 | ||
135 | $innerFilterAggregation = new FilterAggregation( |
|
136 | $aggName, |
|
137 | $boolQuery |
|
138 | ); |
|
139 | $innerFilterAggregation->addAggregation($deepLevelAggregation); |
|
140 | $filterAggregation->addAggregation($innerFilterAggregation); |
|
141 | } |
|
142 | ||
143 | /** |
|
144 | * @param string $key |