{"id":20417713,"url":"https://github.com/pdphilip/laravel-opensearch","last_synced_at":"2026-04-06T01:13:15.362Z","repository":{"id":236845140,"uuid":"793265883","full_name":"pdphilip/laravel-opensearch","owner":"pdphilip","description":"An OpenSearch implementation of Laravel's Eloquent ORM","archived":false,"fork":false,"pushed_at":"2024-11-05T09:37:32.000Z","size":113,"stargazers_count":29,"open_issues_count":5,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T09:11:17.331Z","etag":null,"topics":["eloquent-orm","laravel","opensearch"],"latest_commit_sha":null,"homepage":"https://opensearch.pdphilip.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pdphilip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-28T21:39:53.000Z","updated_at":"2025-03-20T10:28:40.000Z","dependencies_parsed_at":"2024-11-04T10:18:07.349Z","dependency_job_id":"5dc465e8-5993-4620-bc0f-b87fc99bc596","html_url":"https://github.com/pdphilip/laravel-opensearch","commit_stats":null,"previous_names":["pdphilip/laravel-opensearch"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdphilip%2Flaravel-opensearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdphilip%2Flaravel-opensearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdphilip%2Flaravel-opensearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdphilip%2Flaravel-opensearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pdphilip","download_url":"https://codeload.github.com/pdphilip/laravel-opensearch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054230,"owners_count":21039952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eloquent-orm","laravel","opensearch"],"created_at":"2024-11-15T06:27:00.552Z","updated_at":"2026-04-06T01:13:15.357Z","avatar_url":"https://github.com/pdphilip.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg align=\"left\" width=\"70\" height=\"70\" src=\"https://cdn.snipform.io/pdphilip/opensearch/laravel_opensearch.png\"\u003e\n\n# Laravel-OpenSearch\n\n[![Latest Stable Version](http://img.shields.io/github/release/pdphilip/laravel-opensearch.svg)](https://packagist.org/packages/pdphilip/opensearch)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/pdphilip/laravel-opensearch/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/pdphilip/laravel-opensearch/actions/workflows/run-tests.yml?query=branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/pdphilip/laravel-opensearch/phpstan.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/pdphilip/laravel-opensearch/actions/workflows/phpstan.yml?query=branch%3Amain++)\n[![Total Downloads](http://img.shields.io/packagist/dm/pdphilip/opensearch.svg)](https://packagist.org/packages/pdphilip/opensearch)\n\n\u003e [OpenSearch](https://opensearch.net/) is a distributed, community-driven, Apache 2.0-licensed, 100% open-source search and analytics suite used for a broad set of use cases like real-time application monitoring, log analytics, and website\n\u003e search.\n\n## An OpenSearch implementation of Laravel's Eloquent ORM\n\n### The Power of OpenSearch with Laravel's Eloquent\n\nThis 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\npowerful search and analytics capabilities of OpenSearch.\n\nThe Eloquent you already know:\n\n```php\nUserLog::where('created_at','\u003e=',Carbon::now()-\u003esubDays(30))-\u003eget();\n```\n\n```php\nUserLog::create([\n    'user_id' =\u003e '2936adb0-b10d-11ed-8e03-0b234bda3e12',\n    'ip' =\u003e '62.182.98.146',\n    'location' =\u003e [40.7185,-74.0025],\n    'country_code' =\u003e 'US',\n    'status' =\u003e 1,\n]);\n```\n\n```php\nUserLog::where('status', 1)-\u003eupdate(['status' =\u003e 4]);\n```\n\n```php\nUserLog::where('status', 4)-\u003eorderByDesc('created_at')-\u003epaginate(50);\n```\n\n```php\nUserProfile::whereIn('country_code',['US','CA'])\n    -\u003eorderByDesc('last_login')-\u003etake(10)-\u003eget();\n```\n\n```php\nUserProfile::where('state','unsubscribed')\n    -\u003ewhere('updated_at','\u003c=',Carbon::now()-\u003esubDays(90))-\u003edelete();\n```\n\nopensearch with Eloquent:\n\n```php\nUserProfile::searchTerm('Laravel')-\u003eorSearchTerm('opensearch')-\u003eget();\n```\n\n```php\nUserProfile::searchPhrasePrefix('loves espressos and t')-\u003ehighlight()-\u003eget();\n```\n\n```php\nUserProfile::whereMatch('bio', 'PHP')-\u003eget();\n```\n\n```php\nUserLog::whereGeoDistance('location', '10km', [40.7185,-74.0025])-\u003eget();\n```\n\n```php\nUserProfile::whereFuzzy('description', 'qick brwn fx')-\u003eget();\n```\n\nBuilt in Relationships (even to SQL models):\n\n```php\nUserLog::where('status', 1)-\u003eorderByDesc('created_at')-\u003ewith('user')-\u003eget();\n```\n\n---\n\n# Read the [Documentation](https://opensearch.pdphilip.com/)\n\n## Installation\n\n**Laravel 10.x, 11.x \u0026 12.x (main):**\n\n```bash\ncomposer require pdphilip/opensearch\n```\n\n| Laravel Version    | Command                                    | Maintained |\n|--------------------|--------------------------------------------|------------|\n| Laravel 10/11/12   | `composer require pdphilip/opensearch:~3 ` | ✅          |\n| Laravel 10/11 (v2) | `composer require pdphilip/opensearch:~2 ` | ❌ EOL      |\n| Laravel 8 \u0026 9      | `composer require pdphilip/opensearch:~1`  | ❌ EOL      |\n\n## Configuration\n\n1. Set up your `.env` with the following OpenSearch settings:\n\n```ini\nOS_HOSTS=\"http://opensearch:9200\"\nOS_USERNAME=\nOS_PASSWORD=\nOS_INDEX_PREFIX=my_app_\n# prefix will be added to all indexes created by the package with an underscore\n# ex: my_app_user_logs for UserLog.php model\n    \n# AWS SigV4 Config:\nOS_SIG_V4_PROVIDER=\nOS_SIG_V4_REGION=\nOS_SIG_V4_SERVICE=\n\n# Cert Config:\nOS_SSL_CERT=\nOS_SSL_CERT_PASSWORD=\nOS_SSL_KEY=\nOS_SSL_KEY_PASSWORD=\n\n# Optional Settings:\nOS_OPT_VERIFY_SSL=true\nOS_OPT_RETRIES=\nOS_OPT_SNIFF_ON_START=\nOS_OPT_PORT_HOST_HEADERS=\nOS_OPT_ID_SORTABLE=false\nOS_OPT_META_HEADERS=true\nOS_OPT_BYPASS_MAP_VALIDATION=false\nOS_OPT_DEFAULT_LIMIT=1000\n```\n\nFor multiple nodes, pass in as comma-separated:\n\n```ini\nOS_HOSTS=\"http://opensearch-node1:9200,http://opensearch-node2:9200,http://opensearch-node3:9200\"\n```\n\n2. In `config/database.php`, add the OpensSearch connection:\n\n```php\n'opensearch' =\u003e [\n    'driver'       =\u003e 'opensearch',\n    'hosts'        =\u003e explode(',', env('OS_HOSTS', 'http://localhost:9200')),\n    'basic_auth'   =\u003e [\n        'username' =\u003e env('OS_USERNAME', ''),\n        'password' =\u003e env('OS_PASSWORD', ''),\n    ],\n    'sig_v4'       =\u003e [\n        'provider' =\u003e env('OS_SIG_V4_PROVIDER'),\n        'region'   =\u003e env('OS_SIG_V4_REGION'),\n        'service'  =\u003e env('OS_SIG_V4_SERVICE'),\n    ],\n    'ssl'          =\u003e [\n        'cert'          =\u003e env('OS_SSL_CERT', ''),\n        'cert_password' =\u003e env('OS_SSL_CERT_PASSWORD', ''),\n        'key'           =\u003e env('OS_SSL_KEY', ''),\n        'key_password'  =\u003e env('OS_SSL_KEY_PASSWORD', ''),\n    ],\n    'index_prefix' =\u003e env('OS_INDEX_PREFIX', false),\n    'options'      =\u003e [\n        'bypass_map_validation' =\u003e env('OS_OPT_BYPASS_MAP_VALIDATION', false),\n        'ssl_verification'      =\u003e env('OS_OPT_VERIFY_SSL', true),\n        'retires'               =\u003e env('OS_OPT_RETRIES',null),\n        'sniff_on_start'        =\u003e env('OS_OPT_SNIFF_ON_START',false),\n        'logging'               =\u003e env('OS_OPT_LOGGING', false),\n        'port_in_host_header'   =\u003e env('OS_OPT_PORT_HOST_HEADERS',false),\n        'default_limit'         =\u003e env('OS_OPT_DEFAULT_LIMIT', 1000),\n        'allow_id_sort'         =\u003e env('OS_OPT_ID_SORTABLE', false),\n    ],\n],\n```\n\n### 3. If packages are not autoloaded, add the service provider:\n\nFor **Laravel 10 and below**:\n\n```php\n//config/app.php\n'providers' =\u003e [\n    ...\n    ...\n    PDPhilip\\OpenSearch\\OpenSearchServiceProvider::class,\n    ...\n\n```\n\nFor **Laravel 11**:\n\n```php\n//bootstrap/providers.php\n\u003c?php\nreturn [\n    App\\Providers\\AppServiceProvider::class,\n    PDPhilip\\OpenSearch\\OpenSearchServiceProvider::class,\n];\n```\n\nNow, you're all set to use OpenSearch with Laravel as if it were native to the framework.\n\n---\n\n# Documentation Links\n\n### Getting Started\n\n- [Installation](https://opensearch.pdphilip.com/getting-started)\n- [Configuration](https://opensearch.pdphilip.com/getting-started#configuration-guide)\n\n### Eloquent\n\n- [The Base Model](https://opensearch.pdphilip.com/eloquent/the-base-model)\n- [Saving Models](https://opensearch.pdphilip.com/eloquent/saving-models)\n- [Deleting Models](https://opensearch.pdphilip.com/eloquent/deleting-models)\n- [Querying Models](https://opensearch.pdphilip.com/eloquent/querying-models)\n- [Eloquent Queries](https://opensearch.pdphilip.com/eloquent/eloquent-queries)\n- [OS Eloquent Queries](https://opensearch.pdphilip.com/eloquent/os-queries)\n- [Cross Fields Search Queries](https://opensearch.pdphilip.com/eloquent/search-queries)\n- [Aggregation Queries](https://opensearch.pdphilip.com/eloquent/aggregation)\n- [Distinct and GroupBy Queries](https://opensearch.pdphilip.com/eloquent/distinct)\n- [Nested Queries](https://opensearch.pdphilip.com/eloquent/nested-queries)\n- [Ordering and Pagination](https://opensearch.pdphilip.com/eloquent/ordering-and-pagination)\n- [Chunking](https://opensearch.pdphilip.com/eloquent/chunking)\n- [Dynamic Indices](https://opensearch.pdphilip.com/eloquent/dynamic-indices)\n\n### Relationships\n\n- [OpenSearch to OpenSearch](https://opensearch.pdphilip.com/relationships/os-os)\n- [OpenSearch to SQL](https://opensearch.pdphilip.com/relationships/os-sql)\n\n### Migrations: Schema/Index\n\n- [Migrations](https://opensearch.pdphilip.com/schema/migrations)\n- [Index Blueprint](https://opensearch.pdphilip.com/schema/index-blueprint)\n\n### Misc\n\n- [Mapping OS to Eloquent](https://opensearch.pdphilip.com/notes/opensearch-to-eloquent-map)\n\n## Credits\n\n- [David Philip](https://github.com/pdphilip)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdphilip%2Flaravel-opensearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpdphilip%2Flaravel-opensearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdphilip%2Flaravel-opensearch/lists"}