@@ 250-255 (lines=6) @@ | ||
247 | list($path, $field) = explode('>', $this->getDocumentField()); |
|
248 | $boolQuery = new BoolQuery(); |
|
249 | ||
250 | foreach ($terms as $groupName => $term) { |
|
251 | $nestedBoolQuery = new BoolQuery(); |
|
252 | $nestedBoolQuery->add(new TermQuery($field, $term)); |
|
253 | $nestedBoolQuery->add(new TermQuery($this->getNameField(), $groupName)); |
|
254 | $boolQuery->add(new NestedQuery($path, $nestedBoolQuery)); |
|
255 | } |
|
256 | ||
257 | $boolQuery = !empty($boolQuery->getQueries()) ? $boolQuery : new MatchAllQuery(); |
|
258 | $innerFilterAggregation = new FilterAggregation($aggName, $boolQuery); |
@@ 142-153 (lines=12) @@ | ||
139 | foreach ($terms as $groupName => $values) { |
|
140 | $innerBoolQuery = new BoolQuery(); |
|
141 | ||
142 | foreach ($values as $value) { |
|
143 | $nestedBoolQuery = new BoolQuery(); |
|
144 | $nestedBoolQuery->add(new TermQuery($field, $value)); |
|
145 | $nestedBoolQuery->add(new TermQuery($this->getNameField(), $groupName)); |
|
146 | $innerBoolQuery->add( |
|
147 | new NestedQuery( |
|
148 | $path, |
|
149 | $nestedBoolQuery |
|
150 | ), |
|
151 | BoolQuery::SHOULD |
|
152 | ); |
|
153 | } |
|
154 | ||
155 | $boolQuery->add($innerBoolQuery); |
|
156 | } |