| @@ 323-348 (lines=26) @@ | ||
| 320 | * |
|
| 321 | * @return BuilderInterface |
|
| 322 | */ |
|
| 323 | protected function addSubFilterAggregation( |
|
| 324 | $filterAggregation, |
|
| 325 | $deepLevelAggregation, |
|
| 326 | $terms, |
|
| 327 | $aggName |
|
| 328 | ) { |
|
| 329 | list($path, $field) = explode('>', $this->getField()); |
|
| 330 | $boolQuery = new BoolQuery(); |
|
| 331 | ||
| 332 | foreach ($terms as $term) { |
|
| 333 | $boolQuery->add( |
|
| 334 | new NestedQuery($path, new TermQuery($field, $term)) |
|
| 335 | ); |
|
| 336 | } |
|
| 337 | ||
| 338 | if ($boolQuery->getQueries() == []) { |
|
| 339 | $boolQuery->add(new MatchAllQuery()); |
|
| 340 | } |
|
| 341 | ||
| 342 | $innerFilterAggregation = new FilterAggregation( |
|
| 343 | $aggName, |
|
| 344 | $boolQuery |
|
| 345 | ); |
|
| 346 | $innerFilterAggregation->addAggregation($deepLevelAggregation); |
|
| 347 | $filterAggregation->addAggregation($innerFilterAggregation); |
|
| 348 | } |
|
| 349 | ||
| 350 | /** |
|
| 351 | * @param string $key |
|
| @@ 82-107 (lines=26) @@ | ||
| 79 | * |
|
| 80 | * @return BuilderInterface |
|
| 81 | */ |
|
| 82 | protected function addSubFilterAggregation( |
|
| 83 | $filterAggregation, |
|
| 84 | $deepLevelAggregation, |
|
| 85 | $terms, |
|
| 86 | $aggName |
|
| 87 | ) { |
|
| 88 | list($path, $field) = explode('>', $this->getField()); |
|
| 89 | $boolQuery = new BoolQuery(); |
|
| 90 | ||
| 91 | foreach ($terms as $namedTerms) { |
|
| 92 | $boolQuery->add( |
|
| 93 | new NestedQuery($path, new TermsQuery($field, array_values($namedTerms))) |
|
| 94 | ); |
|
| 95 | } |
|
| 96 | ||
| 97 | if ($boolQuery->getQueries() == []) { |
|
| 98 | $boolQuery->add(new MatchAllQuery()); |
|
| 99 | } |
|
| 100 | ||
| 101 | $innerFilterAggregation = new FilterAggregation( |
|
| 102 | $aggName, |
|
| 103 | $boolQuery |
|
| 104 | ); |
|
| 105 | $innerFilterAggregation->addAggregation($deepLevelAggregation); |
|
| 106 | $filterAggregation->addAggregation($innerFilterAggregation); |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * @param string $key |
|