Skip to content

Commit a27c3e6

Browse files
pdphilipgithub-actions[bot]
authored andcommitted
Update CHANGELOG
1 parent ff3c06e commit a27c3e6

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,83 @@
22

33
All notable changes to this `laravel-elasticsearch` package will be documented in this file.
44

5+
## v5.3.0 - 2026-01-20
6+
7+
This release is compatible with Laravel 10, 11 & 12
8+
9+
### New features
10+
11+
#### Distinct with Relations
12+
13+
`distinct()` queries now return [ElasticCollections](https://elasticsearch.pdphilip.com/eloquent/the-base-model#elastic-collections);
14+
15+
If a model relation exists and the **aggregation is done on the foreign key**, you can load the related model
16+
17+
```php
18+
UserLog::where('created_at', '>=', Carbon::now()->subDays(30))
19+
->with('user')
20+
->orderByDesc('_count')
21+
->select('user_id')
22+
->distinct(true);
23+
24+
25+
```
26+
Why: You can now treat distinct aggregations like real Eloquent results, including relationships.
27+
28+
#### Bulk Distinct Queries
29+
30+
New query method `bulkDistinct(array $fields, $includeDocCount = false)` - [Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#bulk-distinct)
31+
32+
Run multiple distinct aggregations **in parallel** within a single Elasticsearch query.
33+
34+
```php
35+
$top3 = UserSession::where('created_at', '>=', Carbon::now()->subDays(30))
36+
->limit(3)
37+
->bulkDistinct(['country', 'device', 'browser_name'], true);
38+
39+
```
40+
Why: Massive performance gains vs running sequential distinct queries.
41+
42+
#### Group By Ranges
43+
44+
`groupByRanges()` performs a [range aggregation](https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-range-aggregation) on the specified field. - [Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#groupby-ranges)
45+
46+
`groupByRanges()->get()` — return bucketed results - [Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#groupby-ranges)
47+
48+
`groupByRanges()->agg()` - apply metric aggregations per bucket -[Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#groupby-ranges-with-aggregations)
49+
50+
#### Group By Date Ranges
51+
52+
`groupByDateRanges()` performs a [date range aggregation](https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-daterange-aggregation) on the specified field. - [Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#groupby-date-ranges)
53+
54+
`groupByDateRanges()->get()` — bucketed date ranges
55+
56+
`groupByDateRanges()->agg()` — metrics per date bucket
57+
58+
#### Model Meta Accessor
59+
60+
New model method `getMetaValue($key)` - [Docs](https://elasticsearch.pdphilip.com/eloquent/the-base-model/#get-model-meta-value)
61+
62+
Convenience method to get a specific meta value from the model instance.
63+
64+
```php
65+
$product = Product::where('color', 'green')->first();
66+
$score = $product->getMetaValue('score');
67+
68+
```
69+
#### Bucket Values in Meta
70+
71+
When a bucketed query is executed, the raw bucket data is now stored in model meta. -[Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#raw-bucket-values-from-meta)
72+
73+
```php
74+
$products = Product::distinct('price');
75+
$buckets = $products->map(function ($product) {
76+
return $product->getMetaValue('bucket');
77+
});
78+
79+
```
80+
**Full Changelog**: https://github.com/pdphilip/laravel-elasticsearch/compare/v5.2.0...v5.3.0
81+
582
## v5.2.0 - 2025-10-24
683

784
This release is compatible with Laravel 10, 11 & 12
@@ -29,6 +106,7 @@ Product::searchQueryString('vanilla +pizza -ice', function (QueryStringOptions $
29106

30107
//etc
31108

109+
32110
```
33111
### Ordering enhancement: unmapped_type
34112

@@ -37,6 +115,7 @@ Product::searchQueryString('vanilla +pizza -ice', function (QueryStringOptions $
37115
```php
38116
Product::query()->orderBy('name', 'desc', ['unmapped_type' => 'keyword'])->get();
39117

118+
40119
```
41120
### Bugfix
42121

@@ -57,6 +136,7 @@ $products = Product::limit(5)->withTrackTotalHits(true)->get();
57136
$totalHits = $products->getQueryMeta()->getTotalHits();
58137

59138

139+
60140
```
61141
This can be set by default for all queries by updating the connection config in `database.php`:
62142

@@ -71,6 +151,7 @@ This can be set by default for all queries by updating the connection config in
71151
],
72152

73153

154+
74155
```
75156
#### 2. New feature, `createOrFail(array $attributes)`
76157

@@ -84,6 +165,7 @@ Product::createOrFail([
84165
]);
85166

86167

168+
87169
```
88170
#### 3. New feature `withRefresh(bool|string $refresh)`
89171

@@ -103,6 +185,7 @@ Product::withRefresh('wait_for')->create([
103185
]);
104186

105187

188+
106189
```
107190
### PRS
108191

@@ -212,6 +295,7 @@ People::bulkInsert([
212295

213296

214297

298+
215299
```
216300
Returns:
217301

@@ -238,6 +322,7 @@ Returns:
238322

239323

240324

325+
241326
```
242327
#### 2. Bug fix: `distinct()` aggregation now appends `searchAfter` key in meta
243328

@@ -279,6 +364,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
279364

280365

281366

367+
282368
```
283369
### Breaking Changes
284370

@@ -312,6 +398,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
312398

313399

314400

401+
315402
```
316403

317404
#### 3. Queries
@@ -332,6 +419,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
332419

333420

334421

422+
335423
```
336424
- `orderByRandom()` Removed
337425

@@ -353,6 +441,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
353441

354442

355443

444+
356445
```
357446
- Legacy Search Methods Removed
358447
All `{xx}->search()` methods been removed. Use `{multi_match}->get()` instead.
@@ -379,6 +468,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
379468

380469

381470

471+
382472
```
383473
- `Schema::hasIndex` has been removed. Use `Schema::hasTable` or `Schema::indexExists` instead.
384474

@@ -449,6 +539,7 @@ Connection::on('elasticsearch')->elastic()->{clientMethod}();
449539

450540

451541

542+
452543
```
453544
### What's Changed
454545

0 commit comments

Comments
 (0)