Skip to content

Commit 465102a

Browse files
committed
Merge branch 'main' into 5.x
2 parents b7197cd + b79d392 commit 465102a

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

CHANGELOG.md

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

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

5+
## v5.1.0 - 2025-08-20
6+
7+
This release is compatible with Laravel 10, 11 & 12
8+
9+
#### 1. New feature, `withTrackTotalHits(bool|int|null $val = true)`
10+
11+
Appends the `track_total_hits` parameter to the DSL query, setting value to `true` will count all the hits embedded in the query meta not capping to Elasticsearch default of 10k hits
12+
13+
```php
14+
$products = Product::limit(5)->withTrackTotalHits(true)->get();
15+
$totalHits = $products->getQueryMeta()->getTotalHits();
16+
17+
```
18+
This can be set by default for all queries by updating the connection config in `database.php`:
19+
20+
```php
21+
'elasticsearch' => [
22+
'driver' => 'elasticsearch',
23+
.....
24+
'options' => [
25+
'track_total_hits' => env('ES_TRACK_TOTAL_HITS', null),
26+
....
27+
],
28+
],
29+
30+
```
31+
#### 2. New feature, `createOrFail(array $attributes)`
32+
33+
By default, when using `create($attributes)` where `$attributes `has an `id` that exists, the operation will upsert. `createOrFail` will throw a `BulkInsertQueryException` with status code `409` if the `id` exists
34+
35+
```php
36+
Product::createOrFail([
37+
'id' => 'some-existing-id',
38+
'name' => 'Blender',
39+
'price' => 30,
40+
]);
41+
42+
```
43+
#### 3. New feature `withRefresh(bool|string $refresh)`
44+
45+
By default, inserting documents will wait for the shards to refresh, ie: `withRefresh(true)`, you can set the refresh flag with the following (as per ES docs):
46+
47+
- `true` (default)
48+
Refresh the relevant primary and replica shards (not the whole index) immediately after the operation occurs, so that the updated document appears in search results immediately.
49+
- `wait_for`
50+
Wait for the changes made by the request to be made visible by a refresh before replying. This doesn’t force an immediate refresh, rather, it waits for a refresh to happen.
51+
- `false`
52+
Take no refresh-related actions. The changes made by this request will be made visible at some point after the request returns.
53+
54+
```php
55+
Product::withRefresh('wait_for')->create([
56+
'name' => 'Blender',
57+
'price' => 30,
58+
]);
59+
60+
```
61+
### PRS
62+
63+
* Add withTrackTotalHits method to Builder class to add track_total_hits by @caufab in https://github.com/pdphilip/laravel-elasticsearch/pull/76
64+
* feat(query): add op_type=create support and dedupe helpers by @abkrim in https://github.com/pdphilip/laravel-elasticsearch/pull/79
65+
66+
### Bugfix
67+
68+
* Laravel ^12.23 Compatibility - close [#81](https://github.com/pdphilip/laravel-elasticsearch/issues/81)
69+
70+
### New Contributors
71+
72+
* @caufab made their first contribution in https://github.com/pdphilip/laravel-elasticsearch/pull/76
73+
74+
**Full Changelog**: https://github.com/pdphilip/laravel-elasticsearch/compare/v5.0.7...v5.1.0
75+
576
## v5.0.7 - 2025-07-13
677

778
This release is compatible with Laravel 10, 11 & 12
@@ -93,6 +164,7 @@ People::bulkInsert([
93164

94165

95166

167+
96168
```
97169
Returns:
98170

@@ -117,6 +189,7 @@ Returns:
117189

118190

119191

192+
120193
```
121194
#### 2. Bug fix: `distinct()` aggregation now appends `searchAfter` key in meta
122195

@@ -156,6 +229,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
156229

157230

158231

232+
159233
```
160234
### Breaking Changes
161235

@@ -187,6 +261,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
187261

188262

189263

264+
190265
```
191266

192267
#### 3. Queries
@@ -205,6 +280,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
205280

206281

207282

283+
208284
```
209285
- `orderByRandom()` Removed
210286

@@ -224,6 +300,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
224300

225301

226302

303+
227304
```
228305
- Legacy Search Methods Removed
229306
All `{xx}->search()` methods been removed. Use `{multi_match}->get()` instead.
@@ -248,6 +325,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
248325

249326

250327

328+
251329
```
252330
- `Schema::hasIndex` has been removed. Use `Schema::hasTable` or `Schema::indexExists` instead.
253331

@@ -316,6 +394,7 @@ Connection::on('elasticsearch')->elastic()->{clientMethod}();
316394

317395

318396

397+
319398
```
320399
### What's Changed
321400

0 commit comments

Comments
 (0)