@@ -252,22 +252,22 @@ |
||
| 252 | 252 | |
| 253 | 253 | public function facet($field, $group = null, $limit = null, $sortField = null, $sortDirection = 'desc') : self |
| 254 | 254 | { |
| 255 | - // reset facets |
|
| 256 | - if ($field === false) { |
|
| 257 | - $this->params['aggs'] = []; |
|
| 258 | - } |
|
| 259 | - if ($group === null) { |
|
| 260 | - $group = $field; |
|
| 261 | - } |
|
| 262 | - $terms = ['field'=>$field]; |
|
| 263 | - if ($limit !==null) { |
|
| 264 | - $terms['size'] = $limit; |
|
| 265 | - } |
|
| 266 | - $this->params['aggs'][$group] = ['terms' =>$terms]; |
|
| 267 | - if ($sortField !== null) { |
|
| 268 | - $this->params['aggs'][$group]['sort'] = [ [$sortField => $sortDirection] ]; |
|
| 269 | - } |
|
| 270 | - return $this; |
|
| 255 | + // reset facets |
|
| 256 | + if ($field === false) { |
|
| 257 | + $this->params['aggs'] = []; |
|
| 258 | + } |
|
| 259 | + if ($group === null) { |
|
| 260 | + $group = $field; |
|
| 261 | + } |
|
| 262 | + $terms = ['field'=>$field]; |
|
| 263 | + if ($limit !==null) { |
|
| 264 | + $terms['size'] = $limit; |
|
| 265 | + } |
|
| 266 | + $this->params['aggs'][$group] = ['terms' =>$terms]; |
|
| 267 | + if ($sortField !== null) { |
|
| 268 | + $this->params['aggs'][$group]['sort'] = [ [$sortField => $sortDirection] ]; |
|
| 269 | + } |
|
| 270 | + return $this; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | public function sort($field, $direction = 'asc', $mode = null): self |
@@ -143,17 +143,17 @@ discard block |
||
| 143 | 143 | public function highlight($fields = [], $settings = []): self |
| 144 | 144 | { |
| 145 | 145 | |
| 146 | - if (count($fields) === 0 && count($settings)===0) { |
|
| 147 | - $this->params['highlight'] = new \stdClass(); |
|
| 146 | + if (count($fields) === 0 && count($settings) === 0) { |
|
| 147 | + $this->params['highlight'] = new \stdClass(); |
|
| 148 | 148 | return $this; |
| 149 | 149 | } |
| 150 | 150 | $this->params['highlight'] = []; |
| 151 | 151 | if (count($fields) > 0) { |
| 152 | - $this->params['highlight']['fields'] =$fields; |
|
| 152 | + $this->params['highlight']['fields'] = $fields; |
|
| 153 | 153 | } |
| 154 | - if (count($settings)>0) { |
|
| 154 | + if (count($settings) > 0) { |
|
| 155 | 155 | foreach ($settings as $name => $value) { |
| 156 | - $this->params['highlight'][$name] =$value; |
|
| 156 | + $this->params['highlight'][$name] = $value; |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | return $this; |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | $group = $field; |
| 261 | 261 | } |
| 262 | 262 | $terms = ['field'=>$field]; |
| 263 | - if ($limit !==null) { |
|
| 263 | + if ($limit !== null) { |
|
| 264 | 264 | $terms['size'] = $limit; |
| 265 | 265 | } |
| 266 | 266 | $this->params['aggs'][$group] = ['terms' =>$terms]; |
| 267 | 267 | if ($sortField !== null) { |
| 268 | - $this->params['aggs'][$group]['sort'] = [ [$sortField => $sortDirection] ]; |
|
| 268 | + $this->params['aggs'][$group]['sort'] = [[$sortField => $sortDirection]]; |
|
| 269 | 269 | } |
| 270 | 270 | return $this; |
| 271 | 271 | } |