| @@ 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 |
|
| @@ 334-359 (lines=26) @@ | ||
| 331 | * |
|
| 332 | * @return BuilderInterface |
|
| 333 | */ |
|
| 334 | protected function addSubFilterAggregation( |
|
| 335 | $filterAggregation, |
|
| 336 | $deepLevelAggregation, |
|
| 337 | $terms, |
|
| 338 | $aggName |
|
| 339 | ) { |
|
| 340 | list($path, $field) = explode('>', $this->getField()); |
|
| 341 | $boolQuery = new BoolQuery(); |
|
| 342 | ||
| 343 | foreach ($terms as $term) { |
|
| 344 | $boolQuery->add( |
|
| 345 | new NestedQuery($path, new TermQuery($field, $term)) |
|
| 346 | ); |
|
| 347 | } |
|
| 348 | ||
| 349 | if ($boolQuery->getQueries() == []) { |
|
| 350 | $boolQuery->add(new MatchAllQuery()); |
|
| 351 | } |
|
| 352 | ||
| 353 | $innerFilterAggregation = new FilterAggregation( |
|
| 354 | $aggName, |
|
| 355 | $boolQuery |
|
| 356 | ); |
|
| 357 | $innerFilterAggregation->addAggregation($deepLevelAggregation); |
|
| 358 | $filterAggregation->addAggregation($innerFilterAggregation); |
|
| 359 | } |
|
| 360 | ||
| 361 | /** |
|
| 362 | * @param string $key |
|