Skip to content

Commit 8f22c78

Browse files
committed
Update CHANGELOG.md
1 parent f4fdbf6 commit 8f22c78

1 file changed

Lines changed: 79 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,80 @@ All notable changes to this `laravel-elasticsearch` package will be documented i
66

77
This release is compatible with Laravel 10, 11 & 12
88

9-
### Added
10-
- **Auto-create index on first query** — When a model queries an index that doesn't exist yet, the index is created automatically instead of throwing `index_not_found_exception`. Matches Elasticsearch's own auto-create behavior for writes, extended to reads. Controlled via `options.auto_create_index` config (default: `true`)
11-
- **Artisan commands**`elastic:status`, `elastic:indices`, `elastic:show {index}` for connection health checks, index listing, and index inspection
12-
- **`upsert()`** — Insert or update records by unique key in a single bulk operation, matching Laravel's native `upsert()` signature. Supports single and batch documents, specific update columns, and composite unique keys
13-
- `TimeOrderedUUIDGenerator` — sortable 20-character IDs where lexicographic order matches chronological order across processes (millisecond granularity)
14-
- `GeneratesTimeOrderedIds` trait with `getRecordTimestamp()` and `getRecordDate()` helpers — safe for mixed datasets (returns null for pre-existing non-time-ordered IDs)
15-
- Schema Builder: `getIndexes()`, `getForeignKeys()`, `getViews()` for Laravel compatibility
16-
- Test suite expanded from 379 to 422 tests (2,548 assertions), all passing. New coverage: upsert variations, advanced aggregations, filter context queries, DSL output inspection, point-in-time pagination, multi-match search, time-ordered IDs
9+
[What's new in v5.4](https://elasticsearch.pdphilip.com/whats-new/#54-new-features)
10+
11+
### New features
12+
13+
#### Auto-Create Index
14+
15+
When a model queries an index that doesn't exist yet, the index is created automatically instead of throwing `index_not_found_exception`. Matches Elasticsearch's own auto-create behavior for writes, extended to reads.
16+
17+
```php
18+
// No migration needed - index is created on first query
19+
$products = Product::where('status', 'active')->get(); // returns empty collection
20+
```
21+
22+
Controlled via `options.auto_create_index` config (default: `true`). - [Docs](https://elasticsearch.pdphilip.com/getting-started/)
23+
24+
Why: New models shouldn't crash before the first write. Elasticsearch already auto-creates on insert; this extends the same behavior to reads.
25+
26+
#### Artisan Commands
27+
28+
First-class CLI tools for managing your Elasticsearch connection and indices:
29+
30+
- `php artisan elastic:status` - Connection health check with cluster info and license details
31+
- `php artisan elastic:indices` - List all indices with health, doc count, and store size
32+
- `php artisan elastic:show {index}` - Inspect an index: overview, mappings, settings, and analysis config
33+
34+
```bash
35+
php artisan elastic:status
36+
php artisan elastic:indices --all
37+
php artisan elastic:show products
38+
```
39+
40+
All commands support `--connection=` for non-default connections.
41+
42+
Why: Until now, inspecting your Elasticsearch setup meant leaving Laravel for curl or Kibana. These commands bring that visibility into Artisan where it belongs.
43+
44+
#### Upsert
45+
46+
New `upsert()` method matching Laravel's native signature. Insert or update records by unique key in a single bulk operation. - [Docs](https://elasticsearch.pdphilip.com/eloquent/saving-models/#upsert)
47+
48+
```php
49+
Product::upsert(
50+
[
51+
['sku' => 'ABC', 'name' => 'Widget', 'price' => 10],
52+
['sku' => 'DEF', 'name' => 'Gadget', 'price' => 20],
53+
],
54+
['sku'], // unique key
55+
['name', 'price'] // columns to update if exists
56+
);
57+
```
58+
59+
Supports single documents, batch operations, and composite unique keys.
60+
61+
Why: Elasticsearch has no native upsert-by-field. This queries for existing documents first, then issues a single bulk request mixing index and update actions.
62+
63+
#### Time-Ordered IDs
64+
65+
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)
66+
67+
```php
68+
use PDPhilip\Elasticsearch\Eloquent\GeneratesTimeOrderedIds;
69+
70+
class TrackingEvent extends Model
71+
{
72+
use GeneratesTimeOrderedIds;
73+
}
74+
75+
$event->id; // "0B3kF5XRABCDE_fghijk"
76+
$event->getRecordTimestamp(); // 1771160093773 (ms)
77+
$event->getRecordDate(); // Carbon instance
78+
```
79+
80+
Safe for mixed datasets; returns `null` for pre-existing IDs not generated by this trait.
81+
82+
Why: When you need IDs that sort chronologically across multiple processes/workers, ideal for high-volume event tracking and time-sequenced analytics.
1783

1884
### Changed
1985
- Refactored Query Builder into focused concerns: `BuildsAggregations`, `BuildsSearchQueries`, `BuildsFieldQueries`, `BuildsGeoQueries`, `BuildsNestedQueries`, `HandlesScripts`, `ManagesPit`
@@ -23,16 +89,17 @@ This release is compatible with Laravel 10, 11 & 12
2389
- Consolidated metadata handling into single `MetaDTO`
2490
- Simplified `ManagesOptions` parameter inference
2591
- Extracted `addFieldQuery()` dispatcher in `BuildsFieldQueries` to deduplicate field query methods
26-
- Refactored Relations for readability: early returns, named variables, simplified loops across `MorphToMany`, `BelongsToMany`, `QueriesRelationships`, `InteractsWithPivotTable`, `ManagesManyToMany`
27-
- Updated `ModelDocs` with comprehensive audit: corrected signatures, added missing methods, removed stale entries
28-
- Added `declare(strict_types=1)` to all ID generation classes and traits
29-
- Consolidated test ID strategy into `TestsWithIdStrategies` trait (removed duplicate `WithIds/` and `IdGenerated/` directories)
92+
- Refactored Relations for readability: early returns, named variables, simplified loops
93+
- Schema Builder: added `getIndexes()`, `getForeignKeys()`, `getViews()` for Laravel compatibility
3094
- CI updated to Elasticsearch 8.18.0
95+
- Test suite expanded from 379 to 422 tests (2,548 assertions), all passing
3196

3297
### Fixed
3398
- `id` is now always present in serialized model output
3499
- Removed dead debug code from Connection.php
35100

101+
**Full Changelog**: https://github.com/pdphilip/laravel-elasticsearch/compare/v5.3.0...v5.4.0
102+
36103
## v5.3.0 - 2026-01-20
37104

38105
This release is compatible with Laravel 10, 11 & 12

0 commit comments

Comments
 (0)