1010This package extends Laravel's Eloquent model and query builder with seamless integration of Elasticsearch functionalities. Designed to feel native to Laravel, this package enables you to work with Eloquent models while leveraging the
1111powerful search and analytics capabilities of Elasticsearch.
1212
13+ Example:
14+
15+ ``` php
16+ $logs = UserLog::where('created_at','>=',Carbon::now()->subDays(30))->get();
17+ ```
18+
19+ ``` php
20+ $updates = UserLog::where('status', 1)->update(['status' => 4]);
21+ ```
22+
23+ ``` php
24+ $profiles = UserProfile::whereIn('country_code',['US','CA'])->orderByDesc('last_login')->take(10)->get();
25+ ```
26+
27+ ``` php
28+ $deleted = UserProfile::where('state','unsubscribed')->where('updated_at','<=',Carbon::now()->subDays(90)->delete();
29+ ```
30+
1331``` php
14- $logs = UserLog::where('type', UserLogType::LOGIN )->where('created_at','>=',Carbon::now( )->subDays(30))->get ();
32+ $search = UserProfile::term('loves espressos' )->minShouldMatch(2 )->highlight()->search ();
1533```
1634
1735### Read the [ Documentation] ( https://elasticsearch.pdphilip.com/ )
1836
1937---
2038
39+ > #### Using [ OpenSearch] ( https://opensearch.pdphilip.com/ ) ? [ Github] ( https://github.com/pdphilip/laravel-opensearch )
40+
41+ ---
42+
43+ > #### [ Package Tests] ( https://github.com/pdphilip/laravel-elasticsearch-tests )
44+
45+ ---
46+
2147## Installation
2248
2349### Maintained versions (Elasticsearch 8.x):
2450
25- Please note: Only ** version 3** of the package will be maintained.
26-
27- ** Laravel 11.x (main):**
51+ ** Laravel 10.x & 11.x (main):**
2852
2953``` bash
3054composer require pdphilip/elasticsearch
3155```
3256
33- | Laravel Version | Command | Maintained |
34- | --------------- | ------------------------------------------------ | ---------- |
35- | Laravel 11.x | ` composer require pdphilip/elasticsearch ` | ✅ |
36- | Laravel 10.x | ` composer require pdphilip/elasticsearch:~3.10 ` | ✅ |
37- | Laravel 9.x | ` composer require pdphilip/elasticsearch:~3.9 ` | ✅ |
38- | Laravel 8.x | ` composer require pdphilip/elasticsearch:~3.8 ` | ✅ |
57+ | Laravel Version | Command | Maintained |
58+ | --------------- | ---------------------------------------------- | ---------- |
59+ | Laravel 10 & 11 | ` composer require pdphilip/elasticsearch:~4 ` | ✅ |
60+ | Laravel 9 | ` composer require pdphilip/elasticsearch:~3.9 ` | ✅ |
61+ | Laravel 8 | ` composer require pdphilip/elasticsearch:~3.8 ` | ✅ |
3962
4063### Unmaintained versions (Elasticsearch 8.x):
4164
@@ -138,6 +161,17 @@ ES_INDEX_PREFIX=my_app
138161
139162### 3. If packages are not autoloaded, add the service provider:
140163
164+ For ** Laravel 11** :
165+
166+ ``` php
167+ //bootstrap/providers.php
168+ <?php
169+ return [
170+ App\Providers\AppServiceProvider::class,
171+ PDPhilip\Elasticsearch\ElasticServiceProvider::class,
172+ ];
173+ ```
174+
141175For ** Laravel 10 and below** :
142176
143177``` php
@@ -150,17 +184,6 @@ For **Laravel 10 and below**:
150184
151185```
152186
153- For ** Laravel 11** :
154-
155- ``` php
156- //bootstrap/providers.php
157- <?php
158- return [
159- App\Providers\AppServiceProvider::class,
160- PDPhilip\Elasticsearch\ElasticServiceProvider::class,
161- ];
162- ```
163-
164187Now, you're all set to use Elasticsearch with Laravel as if it were native to the framework.
165188
166189---
@@ -182,7 +205,7 @@ Now, you're all set to use Elasticsearch with Laravel as if it were native to th
182205- [ Distinct and GroupBy] ( https://elasticsearch.pdphilip.com/distinct )
183206- [ Aggregations] ( https://elasticsearch.pdphilip.com/aggregation )
184207- [ Chunking] ( https://elasticsearch.pdphilip.com/chunking )
185- - [ Nested Queries] ( https://elasticsearch.pdphilip.com/nested-queries ) ** New in Version 3 **
208+ - [ Nested Queries] ( https://elasticsearch.pdphilip.com/nested-queries )
186209- [ Elasticsearch Specific Queries] ( https://elasticsearch.pdphilip.com/es-specific )
187210- [ Full-Text Search] ( https://elasticsearch.pdphilip.com/full-text-search )
188211- [ Dynamic Indices] ( https://elasticsearch.pdphilip.com/dynamic-indices )
@@ -197,14 +220,28 @@ Now, you're all set to use Elasticsearch with Laravel as if it were native to th
197220- [ Migrations] ( https://elasticsearch.pdphilip.com/migrations )
198221- [ Re-indexing Process] ( https://elasticsearch.pdphilip.com/re-indexing )
199222
223+ ## Misc
224+
225+ - [ Handling Errors] ( https://elasticsearch.pdphilip.com/handling-errors )
226+
227+ ---
228+
229+ # New in Version 4
230+
231+ (and 3.9.1/3.8.1)
232+
233+ - [ Search Highlighting] ( https://elasticsearch.pdphilip.com/full-text-search#highlighting )
234+ - [ whereTimestamp()] ( https://elasticsearch.pdphilip.com/es-specific#where-timestamp )
235+ - [ Raw Aggregation] ( https://elasticsearch.pdphilip.com/es-specific#raw-aggregation-queries )
236+ - [ Updated Error Handling] ( https://elasticsearch.pdphilip.com/handling-errors )
237+ - [ Chunk Upgrade: Point In Time (PIT)] ( https://elasticsearch.pdphilip.com/chunking#chunking-under-the-hood-pit )
238+
200239---
201240
202241# New in Version 3
203242
204243### Nested Queries [ (see)] ( https://elasticsearch.pdphilip.com/nested-queries )
205244
206- This update introduces support for querying, sorting and filtering nested data
207-
208245- [ Nested Object Queries] ( https://elasticsearch.pdphilip.com/nested-queries#where-nested-object )
209246- [ Order By Nested] ( https://elasticsearch.pdphilip.com/nested-queries#order-by-nested-field )
210247- [ Filter Nested Values] ( https://elasticsearch.pdphilip.com/nested-queries#filtering-nested-values ) : Filters nested values of the parent collection
0 commit comments