Skip to content

Commit cda0e33

Browse files
committed
init transfer
0 parents  commit cda0e33

35 files changed

+6784
-0
lines changed

LICENSE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Peter David Philip
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8+
persons to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Laravel-OpenSearch
2+
3+
**This package has been built off the back of the original [Elasticsearch version](https://github.com/pdphilip/laravel-elasticsearch) of this package since v3.11.0**
4+
5+
### An OpenSearch implementation of Laravel's Eloquent ORM
6+
7+
This package extends Laravel's Eloquent model and query builder with seamless integration of OpenSearch functionalities. Designed to feel native to Laravel, this package enables you to work with Eloquent models while leveraging the
8+
powerful search and analytics capabilities of OpenSearch.
9+
10+
```php
11+
$logs = UserLog::where('type', UserLogType::LOGIN)->where('created_at','>=',Carbon::now()->subDays(30))->get();
12+
```
13+
14+
### Read the [Documentation](https://elasticsearch.pdphilip.com/)
15+
16+
Note: This package will receive its own version of this documentation. In the meantime, you can reference the Elasticsearch documentation and replace all namespaces `PDPhilip\Elasticsearch\...` with `PDPhilip\OpenSearch\...`
17+
18+
---
19+
20+
## Installation
21+
22+
**Laravel 11.x (main):**
23+
24+
```bash
25+
composer require pdphilip/opensearch
26+
```
27+
28+
## Configuration
29+
30+
1. Set up your `.env` with the following OpenSearch settings:
31+
32+
```ini
33+
OS_HOSTS="http://opensearch:9200"
34+
OS_USERNAME=
35+
OS_PASSWORD=
36+
OS_INDEX_PREFIX=my_app
37+
38+
OS_SIG_V4_PROVIDER=
39+
OS_SIG_V4_REGION=
40+
OS_SIG_V4_SERVICE=
41+
42+
OS_SSL_CERT=
43+
OS_SSL_CERT_PASSWORD=
44+
OS_SSL_KEY=
45+
OS_SSL_KEY_PASSWORD=
46+
47+
OS_OPT_VERIFY_SSL=true
48+
OS_OPT_RETRIES=
49+
OS_OPT_SNIFF_ON_START=
50+
OS_OPT_PORT_HOST_HEADERS=
51+
```
52+
53+
For multiple nodes, pass in as comma-separated:
54+
55+
```ini
56+
ES_HOSTS="http://opensearch-node1:9200,http://opensearch-node2:9200,http://opensearch-node3:9200"
57+
```
58+
59+
2. In `config/database.php`, add the opensearch connection:
60+
61+
```php
62+
'opensearch' => [
63+
'driver' => 'opensearch',
64+
'hosts' => explode(',', env('OS_HOSTS', 'http://localhost:9200')),
65+
'basic_auth' => [
66+
'username' => env('OS_USERNAME', ''),
67+
'password' => env('OS_PASSWORD', ''),
68+
],
69+
'sig_v4' => [
70+
'provider' => env('OS_SIG_V4_PROVIDER'),
71+
'region' => env('OS_SIG_V4_REGION'),
72+
'service' => env('OS_SIG_V4_SERVICE'),
73+
],
74+
'ssl' => [
75+
'cert' => env('OS_SSL_CERT', ''),
76+
'cert_password' => env('OS_SSL_CERT_PASSWORD', ''),
77+
'key' => env('OS_SSL_KEY', ''),
78+
'key_password' => env('OS_SSL_KEY_PASSWORD', ''),
79+
],
80+
'index_prefix' => env('OS_INDEX_PREFIX', false),
81+
'options' => [
82+
'ssl_verification' => env('OS_OPT_VERIFY_SSL', true),
83+
'retires' => env('OS_OPT_RETRIES'),
84+
'sniff_on_start' => env('OS_OPT_SNIFF_ON_START'),
85+
'port_in_host_header' => env('OS_OPT_PORT_HOST_HEADERS'),
86+
],
87+
'query_log' => [
88+
'index' => false, //Or provide a name for the logging index ex: 'laravel_query_logs'
89+
'error_only' => true, //If false, then all queries are logged if the query_log index is set
90+
],
91+
],
92+
```
93+
94+
### 3. If packages are not autoloaded, add the service provider:
95+
96+
For **Laravel 10 and below**:
97+
98+
```php
99+
//config/app.php
100+
'providers' => [
101+
...
102+
...
103+
PDPhilip\OpenSearch\OpenSearchServiceProvider::class,
104+
...
105+
106+
```
107+
108+
For **Laravel 11**:
109+
110+
```php
111+
//bootstrap/providers.php
112+
<?php
113+
return [
114+
App\Providers\AppServiceProvider::class,
115+
PDPhilip\OpenSearch\OpenSearchServiceProvider::class,
116+
];
117+
```
118+
119+
Now, you're all set to use OpenSearch with Laravel as if it were native to the framework.
120+
121+
---
122+
123+
# Documentation Links
124+
125+
## Getting Started
126+
127+
- [Installation](https://elasticsearch.pdphilip.com/#installation)
128+
- [Configuration](https://elasticsearch.pdphilip.com/#configuration)
129+
130+
## Eloquent
131+
132+
- [The Base Model](https://elasticsearch.pdphilip.com/the-base-model)
133+
- [Querying Models](https://elasticsearch.pdphilip.com/querying-models)
134+
- [Saving Models](https://elasticsearch.pdphilip.com/saving-models)
135+
- [Deleting Models](https://elasticsearch.pdphilip.com/deleting-models)
136+
- [Ordering and Pagination](https://elasticsearch.pdphilip.com/ordering-and-pagination)
137+
- [Distinct and GroupBy](https://elasticsearch.pdphilip.com/distinct)
138+
- [Aggregations](https://elasticsearch.pdphilip.com/aggregation)
139+
- [Chunking](https://elasticsearch.pdphilip.com/chunking)
140+
- [Nested Queries](https://elasticsearch.pdphilip.com/nested-queries) **New in Version 3**
141+
- [Elasticsearch Specific Queries](https://elasticsearch.pdphilip.com/es-specific)
142+
- [Full-Text Search](https://elasticsearch.pdphilip.com/full-text-search)
143+
- [Dynamic Indices](https://elasticsearch.pdphilip.com/dynamic-indices)
144+
145+
## Relationships
146+
147+
- [Elasticsearch to Elasticsearch](https://elasticsearch.pdphilip.com/es-es)
148+
- [Elasticsearch to MySQL](https://elasticsearch.pdphilip.com/es-mysql)
149+
150+
## Schema/Index
151+
152+
- [Migrations](https://elasticsearch.pdphilip.com/migrations)
153+
- [Re-indexing Process](https://elasticsearch.pdphilip.com/re-indexing)
154+
155+
---
156+
157+
158+
---

composer.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "pdphilip/opensearch",
3+
"description": "An OpenSearch implementation of Laravel's Eloquent ORM",
4+
"keywords": [
5+
"laravel",
6+
"eloquent",
7+
"OpenSearch",
8+
"database",
9+
"model"
10+
],
11+
"homepage": "https://github.com/pdphilip/laravel-opensearch",
12+
"authors": [
13+
{
14+
"name": "David Philip",
15+
"email": "[email protected]",
16+
"homepage": "https://github.com/pdphilip"
17+
}
18+
],
19+
"license": "MIT",
20+
"require": {
21+
"php": "^8.1",
22+
"illuminate/support": "^9.0|^10.0|^11.0",
23+
"illuminate/container": "^9.0|^10.0|^11.0",
24+
"illuminate/database": "^9.0|^10.0|^11.0",
25+
"illuminate/events": "^^9.0|^10.0|^11.0",
26+
"opensearch-project/opensearch-php": "^2.2"
27+
},
28+
"require-dev": {
29+
"phpunit/phpunit": "^10.3",
30+
"orchestra/testbench": "^8.0",
31+
"mockery/mockery": "^1.4.4",
32+
"doctrine/coding-standard": "12.0.x-dev"
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"PDPhilip\\OpenSearch\\Tests\\": "tests/"
37+
}
38+
},
39+
"autoload": {
40+
"psr-4": {
41+
"PDPhilip\\OpenSearch\\": "src/"
42+
}
43+
},
44+
"extra": {
45+
"laravel": {
46+
"providers": [
47+
"PDPhilip\\OpenSearch\\OpenSearchServiceProvider"
48+
]
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)