PHPackages                             almeida/laravel-elasticsearch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. almeida/laravel-elasticsearch

ActiveLibrary[Search &amp; Filtering](/categories/search)

almeida/laravel-elasticsearch
=============================

Laravel 4.2+ wrapper for ElasticSearch

0.2.0(11y ago)2241MITPHPPHP &gt;=5.4.0

Since Mar 7Pushed 11y agoCompare

[ Source](https://github.com/arnold-almeida/laravel-elasticsearch)[ Packagist](https://packagist.org/packages/almeida/laravel-elasticsearch)[ Docs](https://github.com/arnold-almeida/laravel-elasticsearch)[ RSS](/packages/almeida-laravel-elasticsearch/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

### Preamble

[](#preamble)

I need to improve search. Currently using mongob, 2dspheres etc.

Bring on Elasticsearch. Basically just a wrapper for the offical client.

##### Afternoon hack

[](#afternoon-hack)

- Trying to put togeter a nice package so we can use ElasticSearch easily
- Should play well with league/fractal
- Should play well with illuminate/collections
- Should play well with fractal/item
- Should play well with fractal/resources
- etc..

### Install via Composer

[](#install-via-composer)

```
require : {
	"almeida/laravel-elasticsearch" : "dev-master"
}

```

### Step 1

[](#step-1)

Extend the abstract `ElasticDocument` so you get some easy CRUD.

Let's assume we are working with movies.

```
/**
 * Acme\Search\MovieDocument
 */
class MovieDocument extends \Almeida\LaravelElasticSearch\ElasticDocumentAbstract
{
	protected $index = 'movie_cluster';

	protected $type = 'movies';

	public function setId($movie) {
		return $movie->id;
	}

}
```

### Creating / Updating an index

[](#creating--updating-an-index)

Create an index.

Assuming you have already a working `fractal/transformer`

```
	$options = [];
	$options['transformer'] = 'Acme\MovieTransformer';

	$document = new \Acme\Search\MovieDocument($options);
	$document->setBody($movie);
	$document->index();
	// or $document->create();
	// or $document->update();

	// OR
	$document = new \Acme\Search\MovieDocument();
	$document->setBody($movie);
	$document->setTransformer('Acme\MovieTransformer');
	$document->index();
```

### Deleting an index (@todo)

[](#deleting-an-index-todo)

Deleting an index.

```
	$document = new \Acme\Search\MovieDocument();
	$document->delete($movie->id);
```

### Indexing en masse in the Console

[](#indexing-en-masse-in-the-console)

```
	$n = 0;

	Movie::chunk(100, function($movies) use(&$n) {

		foreach ($movies as $i => $movie) {

			$document = new \Acme\Search\MovieDocument();
			$document->setBody($movie);
			$document->setTransformer('Acme\MovieTransformer');
			$document->index();

			$this->info("Indexed : {$movie->title}");

			$n++;
		}
	});

	$this->info("Indexed [{$n}] movies");
```

#### Searching (WIP)

[](#searching-wip)

Promise to work on it over the next few days.

```
	$movieTitle = 'Scarface';
	$document->basicSearch($movieTitle);
```

### Todo

[](#todo)

- think about this more
- Move search, stats, and aggerates to Traits so we only use them on applicable documents

GOTCHAS
-------

[](#gotchas)

Deving locally on OSX i couldnt get the client to connect to elasticsearch even though i could access it in the browser at

This fixed it for now...

-

The correct way to access is actually through,

Will work it out when i sort out nicer config etc.

### Required reading

[](#required-reading)

-
- [http://www.elastic.co/guide/en/elasticsearch/client/php-api/current/\_quickstart.html](http://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_quickstart.html)

##### Relevance

[](#relevance)

How is it calculated ?

-

##### Monitoring elasticsearch using Marvel (dev)

[](#monitoring-elasticsearch-using-marvel-dev)

### Thanks for the notes

[](#thanks-for-the-notes)

-
-
-
-
-
-
-

I accept bitcoin tips. \[18tEqEUnyJaqvKh3CCNAAai9seztLb3Tw9\].

They should too! Come on its going to be a thing.

### LICENSE

[](#license)

MIT

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~34 days

Total

2

Last Release

4051d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c6cf551853c66b9750383a7db67b8213413f85c9509f07e09c4e8093c334b23?d=identicon)[almeida](/maintainers/almeida)

---

Top Contributors

[![arnold-almeida](https://avatars.githubusercontent.com/u/53209?v=4)](https://github.com/arnold-almeida "arnold-almeida (13 commits)")

---

Tags

laravelelasticsearch

### Embed Badge

![Health badge](/badges/almeida-laravel-elasticsearch/health.svg)

```
[![Health](https://phpackages.com/badges/almeida-laravel-elasticsearch/health.svg)](https://phpackages.com/packages/almeida-laravel-elasticsearch)
```

###  Alternatives

[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

397612.3k](/packages/jeroen-g-explorer)[baijunyao/laravel-scout-elasticsearch

Elasticsearch Driver for Laravel Scout

8023.7k1](/packages/baijunyao-laravel-scout-elasticsearch)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
