Skip to content

Commit c1cb0dc

Browse files
committed
Merge remote-tracking branch 'origin/dev-main' into dev-l9
2 parents 178ab82 + 1b2568f commit c1cb0dc

File tree

3 files changed

+100
-28
lines changed

3 files changed

+100
-28
lines changed

README.md

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,55 @@
1010
This 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
1111
powerful 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
3054
composer 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+
141175
For **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-
164187
Now, 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

src/Connection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Connection extends BaseConnection
2323
protected $elasticMetaHeader = null;
2424
protected $rebuild = false;
2525

26+
2627
public function __construct(array $config)
2728
{
2829
$this->config = $config;

src/Schema/IndexBlueprint.php

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,60 @@ public function keyword($field): Definitions\FieldDefinition
5353
return $this->addField('keyword', $field);
5454
}
5555

56+
57+
//----------------------------------------------------------------------
58+
// Numeric Types
59+
//----------------------------------------------------------------------
60+
61+
public function long($field): Definitions\FieldDefinition
62+
{
63+
return $this->addField('long', $field);
64+
}
65+
5666
public function integer($field): Definitions\FieldDefinition
5767
{
5868
return $this->addField('integer', $field);
5969
}
6070

61-
public function long($field): Definitions\FieldDefinition
71+
public function short($field): Definitions\FieldDefinition
6272
{
63-
return $this->addField('long', $field);
73+
return $this->addField('short', $field);
74+
}
75+
76+
public function byte($field): Definitions\FieldDefinition
77+
{
78+
return $this->addField('byte', $field);
79+
}
80+
81+
public function double($field): Definitions\FieldDefinition
82+
{
83+
return $this->addField('double', $field);
6484
}
6585

6686
public function float($field): Definitions\FieldDefinition
6787
{
6888
return $this->addField('float', $field);
6989
}
7090

71-
public function short($field): Definitions\FieldDefinition
91+
public function halfFloat($field): Definitions\FieldDefinition
7292
{
73-
return $this->addField('short', $field);
93+
return $this->addField('half_float', $field);
94+
}
95+
96+
public function scaledFloat($field, $scalingFactor = 100): Definitions\FieldDefinition
97+
{
98+
return $this->addField('scaled_float', $field, [
99+
'scaling_factor' => $scalingFactor,
100+
]);
74101
}
75102

103+
public function unsignedLong($field): Definitions\FieldDefinition
104+
{
105+
return $this->addField('unsigned_long', $field);
106+
}
107+
108+
//----------------------------------------------------------------------
109+
76110
public function date($field, $format = null): Definitions\FieldDefinition
77111
{
78112
if ($format) {

0 commit comments

Comments
 (0)