Skip to content

Commit b532fc5

Browse files
committed
Update CHANGELOG.md
1 parent 54d05c1 commit b532fc5

1 file changed

Lines changed: 49 additions & 36 deletions

File tree

CHANGELOG.md

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ All notable changes to this `laravel-elasticsearch` package will be documented i
99
- `Schema::compileMapping()` — compile a Blueprint callback into its resulting ES mapping structure without creating the index. Useful for debugging and previewing what `mappingDefinition()` will produce.
1010
- `Grammar::compileMapping()` — public access to the Blueprint-to-properties compilation pipeline.
1111

12-
### Improved
13-
14-
- `elastic:re-index` mapping analysis now uses `getMappings()` + `compileMapping()` for a proper apples-to-apples comparison, replacing the manual tree-building approach. Correctly handles nested types with properties, multi-field types with sub-fields, and any combination at any depth.
15-
- `elastic:re-index` output uses `dataList` depth rendering for both "Fields to Update" and "Unmapped Fields", showing nested structures with proper indentation.
16-
1712
### Fixed
1813

1914
- `elastic:re-index` now correctly detects nested field mappings (e.g., `nested('tags')->properties(...)`) including their sub-fields and keyword sub-field changes.
@@ -30,14 +25,16 @@ This release is compatible with Laravel 10, 11 & 12
3025

3126
#### Automated Re-indexing Command
3227

33-
New `elastic:re-index` command that automates the entire re-indexing process when your field mappings change. Pass a model name and the command handles the rest — creating a temp index, copying data, verifying counts, swapping, and cleaning up across 9 interactive phases with confirmation prompts between each step. - [Docs](https://elasticsearch.pdphilip.com/schema/artisan-commands/#elasticre-index)
28+
New `elastic:re-index` command that automates the entire re-indexing process when your field mappings change. Pass a model name and the command handles the rest — creating a temp index, copying data, verifying counts, swapping, and cleaning
29+
up across 9 interactive phases with confirmation prompts between each step. - [Docs](https://elasticsearch.pdphilip.com/schema/artisan-commands/#elasticre-index)
3430

3531
```bash
3632
php artisan elastic:re-index UserLog
3733
php artisan elastic:re-index "App\Models\ES\UserLog"
3834
```
3935

4036
Features include:
37+
4138
- Smart mapping analysis that detects type mismatches and sub-field changes (e.g., adding `hasKeyword: true`)
4239
- Resume capability — interrupted runs pick up where they left off
4340
- Configurable tolerance and retry settings
@@ -54,7 +51,8 @@ php artisan elastic:make ES/UserLog
5451

5552
#### Mapping Definition on Models
5653

57-
Define your index field mappings directly on the model by overriding `mappingDefinition()`. Uses the same Blueprint syntax as migrations. Powers the `elastic:re-index` command's mapping analysis. - [Docs](https://elasticsearch.pdphilip.com/eloquent/the-base-model/#mapping-definition)
54+
Define your index field mappings directly on the model by overriding `mappingDefinition()`. Uses the same Blueprint syntax as migrations. Powers the `elastic:re-index` command's mapping
55+
analysis. - [Docs](https://elasticsearch.pdphilip.com/eloquent/the-base-model/#mapping-definition)
5856

5957
```php
6058
public static function mappingDefinition(Blueprint $index): void
@@ -141,7 +139,8 @@ Why: Elasticsearch has no native upsert-by-field. This queries for existing docu
141139

142140
#### Time-Ordered IDs
143141

144-
New `GeneratesTimeOrderedIds` trait for sortable, chronologically-ordered IDs. 20 characters, URL-safe, lexicographic sort matches creation order across processes. - [Docs](https://elasticsearch.pdphilip.com/eloquent/the-base-model/#time-ordered-ids)
142+
New `GeneratesTimeOrderedIds` trait for sortable, chronologically-ordered IDs. 20 characters, URL-safe, lexicographic sort matches creation order across
143+
processes. - [Docs](https://elasticsearch.pdphilip.com/eloquent/the-base-model/#time-ordered-ids)
145144

146145
```php
147146
use PDPhilip\Elasticsearch\Eloquent\GeneratesTimeOrderedIds;
@@ -161,6 +160,7 @@ Safe for mixed datasets; returns `null` for pre-existing IDs not generated by th
161160
Why: When you need IDs that sort chronologically across multiple processes/workers, ideal for high-volume event tracking and time-sequenced analytics.
162161

163162
### Changed
163+
164164
- Refactored Query Builder into focused concerns: `BuildsAggregations`, `BuildsSearchQueries`, `BuildsFieldQueries`, `BuildsGeoQueries`, `BuildsNestedQueries`, `HandlesScripts`, `ManagesPit`
165165
- Refactored Grammar into concerns: `CompilesAggregations`, `CompilesOrders`, `CompilesWheres`, `FieldUtilities`
166166
- Decomposed `ElasticsearchModel` trait into focused traits for clarity
@@ -174,6 +174,7 @@ Why: When you need IDs that sort chronologically across multiple processes/worke
174174
- Test suite expanded from 379 to 422 tests (2,548 assertions), all passing
175175

176176
### Fixed
177+
177178
- `id` is now always present in serialized model output (`toArray()`, `toJson()`)
178179
- `_id` is no longer exposed in serialized output (internal metadata stays internal)
179180
- Removed dead debug code from Connection.php
@@ -201,6 +202,7 @@ UserLog::where('created_at', '>=', Carbon::now()->subDays(30))
201202

202203

203204
```
205+
204206
Why: You can now treat distinct aggregations like real Eloquent results, including relationships.
205207

206208
#### Bulk Distinct Queries
@@ -215,19 +217,22 @@ $top3 = UserSession::where('created_at', '>=', Carbon::now()->subDays(30))
215217
->bulkDistinct(['country', 'device', 'browser_name'], true);
216218

217219
```
220+
218221
Why: Massive performance gains vs running sequential distinct queries.
219222

220223
#### Group By Ranges
221224

222-
`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)
225+
`groupByRanges()` performs a [range aggregation](https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-range-aggregation) on the specified
226+
field. - [Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#groupby-ranges)
223227

224228
`groupByRanges()->get()` — return bucketed results - [Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#groupby-ranges)
225229

226-
`groupByRanges()->agg()` - apply metric aggregations per bucket -[Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#groupby-ranges-with-aggregations)
230+
`groupByRanges()->agg()` - apply metric aggregations per bucket -[Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#groupby-ranges-with-aggregations)
227231

228232
#### Group By Date Ranges
229233

230-
`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)
234+
`groupByDateRanges()` performs a [date range aggregation](https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-daterange-aggregation) on the specified
235+
field. - [Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/#groupby-date-ranges)
231236

232237
`groupByDateRanges()->get()` — bucketed date ranges
233238

@@ -244,6 +249,7 @@ $product = Product::where('color', 'green')->first();
244249
$score = $product->getMetaValue('score');
245250

246251
```
252+
247253
#### Bucket Values in Meta
248254

249255
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)
@@ -255,6 +261,7 @@ $buckets = $products->map(function ($product) {
255261
});
256262

257263
```
264+
258265
**Full Changelog**: https://github.com/pdphilip/laravel-elasticsearch/compare/v5.2.0...v5.3.0
259266

260267
## v5.2.0 - 2025-10-24
@@ -286,6 +293,7 @@ Product::searchQueryString('vanilla +pizza -ice', function (QueryStringOptions $
286293

287294

288295
```
296+
289297
### Ordering enhancement: unmapped_type
290298

291299
- You can now add an `unmapped_type` flag to your ordering query #88
@@ -295,6 +303,7 @@ Product::query()->orderBy('name', 'desc', ['unmapped_type' => 'keyword'])->get()
295303

296304

297305
```
306+
298307
### Bugfix
299308

300309
- Fixed issue where limit values were being reset on bucket aggregations #84
@@ -316,6 +325,7 @@ $totalHits = $products->getQueryMeta()->getTotalHits();
316325

317326

318327
```
328+
319329
This can be set by default for all queries by updating the connection config in `database.php`:
320330

321331
```php
@@ -331,6 +341,7 @@ This can be set by default for all queries by updating the connection config in
331341

332342

333343
```
344+
334345
#### 2. New feature, `createOrFail(array $attributes)`
335346

336347
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
@@ -345,6 +356,7 @@ Product::createOrFail([
345356

346357

347358
```
359+
348360
#### 3. New feature `withRefresh(bool|string $refresh)`
349361

350362
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):
@@ -365,6 +377,7 @@ Product::withRefresh('wait_for')->create([
365377

366378

367379
```
380+
368381
### PRS
369382

370383
* Add withTrackTotalHits method to Builder class to add track_total_hits by @caufab in https://github.com/pdphilip/laravel-elasticsearch/pull/76
@@ -406,9 +419,9 @@ This release is compatible with Laravel 10, 11 & 12
406419

407420
### What's Changed
408421

409-
* Merging in bug fixes by @use-the-fork in https://github.com/pdphilip/laravel-elasticsearch/pull/65
422+
* Merging in bug fixes by @use-the-fork in https://github.com/pdphilip/laravel-elasticsearch/pull/65
410423
* Updated outstanding tests
411-
* Fixed bug in relations`has()` method
424+
* Fixed bug in relations`has()` method
412425

413426
**Full Changelog**: https://github.com/pdphilip/laravel-elasticsearch/compare/v5.0.4...v5.0.5
414427

@@ -475,6 +488,7 @@ People::bulkInsert([
475488

476489

477490
```
491+
478492
Returns:
479493

480494
```json
@@ -502,6 +516,7 @@ Returns:
502516

503517

504518
```
519+
505520
#### 2. Bug fix: `distinct()` aggregation now appends `searchAfter` key in meta
506521

507522
**Full Changelog**: https://github.com/pdphilip/laravel-elasticsearch/compare/v5.0.1...v5.0.2
@@ -530,9 +545,8 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
530545
### Upgrading
531546

532547
- Please take a look at the [upgrade guide](https://elasticsearch.pdphilip.com/upgrade-guide/) carefully, as there are several significant breaking changes.
533-
548+
534549
- [New features are detailed here](https://elasticsearch.pdphilip.com/whats-new/)
535-
536550

537551
```json
538552
"pdphilip/elasticsearch": "^5",
@@ -544,6 +558,7 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
544558

545559

546560
```
561+
547562
### Breaking Changes
548563

549564
#### 1. Connection
@@ -558,10 +573,10 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
558573
- **Model ID Field**
559574
`$model->_id` is deprecated. Use `$model->id` instead.
560575
If your model had a separate `id` field, you must rename it.
561-
576+
562577
- **Default Limit Constant**
563578
`MAX_SIZE` constant is removed. Use `$defaultLimit` property:
564-
579+
565580
```php
566581
use PDPhilip\Elasticsearch\Eloquent\Model;
567582

@@ -582,9 +597,9 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
582597
#### 3. Queries
583598

584599
- `where()` Behavior Changed
585-
600+
586601
Now uses term query instead of match.
587-
602+
588603
```php
589604
// Old:
590605
Product::where('name', 'John')->get(); // match query
@@ -600,13 +615,13 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
600615

601616
```
602617
- `orderByRandom()` Removed
603-
618+
604619
Replace with `functionScore()` [Docs](https://elasticsearch.pdphilip.com/upgrade-guide#queries)
605-
620+
606621
- Full-text Search Options Updated
607622
Methods like `asFuzzy()`, `setMinShouldMatch()`, `setBoost()` removed.
608623
Use callback-based SearchOptions instead:
609-
624+
610625
```php
611626
Product::searchTerm('espresso time', function (SearchOptions $options) {
612627
$options->searchFuzzy();
@@ -623,19 +638,17 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
623638
```
624639
- Legacy Search Methods Removed
625640
All `{xx}->search()` methods been removed. Use `{multi_match}->get()` instead.
626-
627641

628642
#### 4. Distinct & GroupBy
629643

630644
- `distinct()` and `groupBy()` behavior updated. [Docs](https://elasticsearch.pdphilip.com/eloquent/distinct/)
631-
645+
632646
Review queries using them and refactor accordingly.
633-
634647

635648
#### 5. Schema
636649

637650
- `IndexBlueprint` and `AnalyzerBlueprint` has been removed and replaced with a single `Blueprint` class
638-
651+
639652
```diff
640653
- use PDPhilip\Elasticsearch\Schema\IndexBlueprint;
641654
- use PDPhilip\Elasticsearch\Schema\AnalyzerBlueprint;
@@ -649,25 +662,24 @@ with Laravel’s Eloquent. It lays a solid, future-proof foundation for everythi
649662

650663
```
651664
- `Schema::hasIndex` has been removed. Use `Schema::hasTable` or `Schema::indexExists` instead.
652-
665+
653666
- `geo($field)` field property has been replaced with `geoPoint($field)`
654-
667+
655668
- `{field}->index($bool)` field property has been replaced with `{field}->indexField($bool)`;
656-
669+
657670
- `alias()` field type has been removed. Use `aliasField()` instead.
658-
671+
659672
- `settings()` method has been replaced with `withSetting()`
660-
673+
661674
- `map()` method has been replaced with `withMapping()`
662-
675+
663676
- `analyzer()` method has been replaced with `addAnalyzer()`
664-
677+
665678
- `tokenizer()` method has been replaced with `addTokenizer()`
666-
679+
667680
- `charFilter()` method has been replaced with `addCharFilter()`
668-
681+
669682
- `filter()` method has been replaced with `addFilter()`
670-
671683

672684
#### 6. Dynamic Indices
673685

@@ -719,6 +731,7 @@ Connection::on('elasticsearch')->elastic()->{clientMethod}();
719731

720732

721733
```
734+
722735
### What's Changed
723736

724737
* V5.0.0 by @use-the-fork in https://github.com/pdphilip/laravel-elasticsearch/pull/54

0 commit comments

Comments
 (0)