Skip to content

Commit 7481129

Browse files
authored
Merge pull request #7 from ensi-platform/task-96329
#96329 Count aggregation and sort missing values
2 parents 901db27 + 688f6d0 commit 7481129

File tree

17 files changed

+670
-24
lines changed

17 files changed

+670
-24
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ $searchQuery->whereMultiMatch([], 'query string'); // search by all text fields
8383
### Sorting
8484

8585
```php
86-
$searchQuery->sortBy('field', 'desc', 'max'); // field is from main document
86+
$searchQuery->sortBy('field', SortOrder::DESC, SortMode::MAX, MissingValuesMode::FIRST); // field is from main document
8787
$searchQuery->sortByNested(
8888
'nested_field',
8989
fn(SortableQuery $subQuery) => $subQuery->where('field_in_nested', 'value')->sortBy('field')
@@ -134,6 +134,7 @@ $aggQuery = ProductsIndex::aggregate();
134134
$aggs = $aggQuery
135135
->where('active', true)
136136
->terms('codes', 'code')
137+
->count('product_count', 'product_id')
137138
->nested(
138139
'offers',
139140
fn(AggregationsBuilder $builder) => $builder->where('seller_id', 10)->minmax('price', 'price')
@@ -153,7 +154,7 @@ Aggregate names must be unique for whole query.
153154
Get all variants of attribute values:
154155

155156
```php
156-
$aggQuery->terms('agg_name', 'field');
157+
$aggQuery->terms('agg_name', 'field', 25);
157158
```
158159

159160
Get min and max attribute values. E.g for date:
@@ -162,6 +163,13 @@ Get min and max attribute values. E.g for date:
162163
$aggQuery->minmax('agg_name', 'field');
163164
```
164165

166+
Get count unique attribute values:
167+
168+
```php
169+
$aggQuery->count('agg_name', 'field');
170+
```
171+
172+
165173
Aggregation plays nice with nested documents.
166174

167175
```php

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"require": {
1717
"php": "^8.0",
1818
"elasticsearch/elasticsearch": "^7.13",
19-
"illuminate/support": "^8.0||^9.0"
19+
"illuminate/support": "^8.0||^9.0",
20+
"webmozart/assert": "^1.11"
2021
},
2122
"require-dev": {
2223
"friendsofphp/php-cs-fixer": "^3.2",

0 commit comments

Comments
 (0)