# Laravel-Elasticsearch > An Elasticsearch implementation of Laravel's Eloquent ORM. Extends Laravel's Eloquent model and query builder with seamless Elasticsearch integration — search queries, aggregations, geo-spatial queries, nested objects, and more — using familiar Eloquent syntax. - Package: pdphilip/elasticsearch v5 for Laravel 10, 11 & 12 with Elasticsearch 8.x - Docs: https://elasticsearch.pdphilip.com - GitHub: https://github.com/pdphilip/laravel-elasticsearch - Last updated: 2026-05-24 ## Introduction - [Getting Started](https://elasticsearch.pdphilip.com/getting-started/): Kickstart your journey with Elasticsearch integration in Laravel, leveraging the powerful search and analytics capabilities alongside the familiar Eloquent ORM. - [What's New in V5](https://elasticsearch.pdphilip.com/whats-new/): V5 represents a near-complete rewrite of the Laravel-Elasticsearch package. This update delivers a more seamless integration with Laravel's Models, Eloquent, and Query Builders while providing greater access to Elasticsearch's advanced features. - [Upgrading from V4](https://elasticsearch.pdphilip.com/upgrade-guide/): An Elasticsearch implementation of Laravel's Eloquent ORM ## Schema / Index - [Migrations](https://elasticsearch.pdphilip.com/schema/migrations/): Elasticsearch index management differs significantly from traditional SQL schema operations. This package provides a fully custom schema layer tailored to Elasticsearch’s structure and capabilities. - [Index Blueprint](https://elasticsearch.pdphilip.com/schema/index-blueprint/): This guide walks you through defining Elasticsearch index schemas using Laravel, including field types, parameters, and advanced settings. - [Re-indexing Guide](https://elasticsearch.pdphilip.com/schema/re-indexing/): Re-indexing in Elasticsearch is a critical operation, especially when you need to alter the mapping of existing data. This process involves creating a new index with the desired mappings and copying the data from the old index to the new one. Here\'s a step-by-step example of how this can be achieved using the schema functionality of this plugin. ## Eloquent - [The Base Model](https://elasticsearch.pdphilip.com/eloquent/the-base-model/): This package provides an Elasticsearch-compatible Eloquent class, allowing you to define models for your Elasticsearch indices. - [Saving Models](https://elasticsearch.pdphilip.com/eloquent/saving-models/): Using Laravel-Elasticsearch integration allows developers to save models in a way that aligns with the typical Eloquent patterns used in Laravel, making it easier to switch from or use alongside traditional relational models. - [Deleting Models](https://elasticsearch.pdphilip.com/eloquent/deleting-models/): The Laravel-Elasticsearch integration facilitates model deletion in a manner that\'s highly consistent with the Laravel Eloquent ORM, offering a familiar interface for developers - [Querying Models](https://elasticsearch.pdphilip.com/eloquent/querying-models/): Query models in Elasticsearch using the same Eloquent-style syntax you're familiar with - [Eloquent Queries](https://elasticsearch.pdphilip.com/eloquent/eloquent-queries/): This section covers the most common query methods directly from Laravel, mapped to Elasticsearch DSL under the hood. - [ES Eloquent Queries](https://elasticsearch.pdphilip.com/eloquent/es-queries/): Elasticsearch offers a rich set of query capabilities, including geospatial queries and regex-based searches, which go beyond the traditional query types found in SQL databases. The Laravel-Elasticsearch integration provides a seamless interface to leverage these powerful features directly within your Laravel models. - [Search Queries](https://elasticsearch.pdphilip.com/eloquent/search-queries/): Cross fields search queries tap into Elasticsearch's text analysis features, allowing for sophisticated searches across text fields. - [Query String Queries](https://elasticsearch.pdphilip.com/eloquent/query-string-queries/): Query String Queries leverage Elasticsearch’s powerful query_string syntax to perform advanced full-text and structured searches directly on your Laravel models. - [Aggregation Queries](https://elasticsearch.pdphilip.com/eloquent/aggregation/): Aggregations are powerful tools in Elasticsearch that allow you to summarize, compute statistics, and analyze data trends within your dataset. In the Laravel-Elasticsearch integration, aggregations are simplified to align with Eloquent's method of handling aggregate functions, making it intuitive for developers to perform complex data analysis. - [Distinct / GroupBy Queries](https://elasticsearch.pdphilip.com/eloquent/distinct/): In the Laravel-Elasticsearch integration, distinct() and groupBy() methods play a pivotal role in data aggregation, especially when retrieving unique field values or aggregating grouped data summaries. - [Nested Queries](https://elasticsearch.pdphilip.com/eloquent/nested-queries/): Nested queries are a powerful feature of Elasticsearch that allows you to search within nested objects or arrays. This feature is especially useful when working with complex data structures that require deep search capabilities. - [Ordering and Pagination](https://elasticsearch.pdphilip.com/eloquent/ordering-and-pagination/): In the Laravel-Elasticsearch integration, ordering and pagination are essential features that enable developers to manage and present data effectively. These features are designed to work seamlessly within the Laravel ecosystem, designed to feel native to Laravel developers familiar with Eloquent - [Chunking](https://elasticsearch.pdphilip.com/eloquent/chunking/): In scenarios where you're dealing with large datasets, Laravel's chunk method becomes invaluable, allowing you to process large sets of results in manageable portions. This approach is particularly useful in memory-intensive operations, such as batch updates or exports, where loading the entire dataset into memory at once could lead to performance issues. The Laravel-Elasticsearch integration adapts this familiar concept from Laravel Eloquent ORM to work within the context of Elasticsearch data. - [Dynamic Indices](https://elasticsearch.pdphilip.com/eloquent/dynamic-indices/): In certain scenarios, it may be necessary to distribute a model's data across multiple Elasticsearch indices to optimize performance, manage data volume, or comply with specific data storage requirements. The Laravel-Elasticsearch integration accommodates this need through the support for dynamic indices, allowing a single model to interact with a range of indices following a consistent naming pattern. ## Relationships - [Elasticsearch to Elasticsearch](https://elasticsearch.pdphilip.com/relationships/es-es/): In Laravel applications, model relationships are crucial for structuring complex data and interactions between different entities. The Laravel-Elasticsearch integration supports a variety of relationship types, enabling Elasticsearch documents to relate to each other similarly to how models relate in traditional relational databases. This section provides a comprehensive guide on implementing Elasticsearch-to-Elasticsearch model relationships within a Laravel application. - [Elasticsearch to SQL](https://elasticsearch.pdphilip.com/relationships/es-sql/): In many applications, Elasticsearch is used in conjunction with a relational database like MySQL. The Laravel-Elasticsearch integration allows you to define hybrid relationships between Elasticsearch and MySQL models seamlessly. This enables a flexible and powerful architecture for applications that need the speed and scalability of Elasticsearch along with the reliability and consistency of a relational database. ## Notes / Resources - [ES to Eloquent Map](https://elasticsearch.pdphilip.com/notes/elasticsearch-to-eloquent-map/): Glossary of common Elasticsearch queries and their Eloquent equivalents, providing a quick reference for developers coming from Elasticsearch to Laravel's Eloquent. - [Handling Errors](https://elasticsearch.pdphilip.com/notes/handling-errors/): This package returns errors that are more readable than Elasticsearch's default responses. And embeds helpful metadata to help elucidate the issue. - [Elasticsearch Quirks](https://elasticsearch.pdphilip.com/notes/elasticsearch-quirks/): Understanding Elasticsearch's unique behaviors can significantly improve your interaction with it, especially when using it through this Laravel plugin. Here are some common scenarios you might encounter ## ElasticLens ElasticLens (pdphilip/elasticlens) is a separate package that creates searchable Elasticsearch indexes from your SQL models using this package as its query engine. - [ElasticLens Docs](https://elasticlens.pdphilip.com): Full documentation for ElasticLens - [ElasticLens llms.txt](https://elasticlens.pdphilip.com/llms.txt): LLM-friendly ElasticLens documentation index - [ElasticLens llms-full.txt](https://elasticlens.pdphilip.com/llms-full.txt): Complete ElasticLens documentation