PHPackages                             tamayo/stretchy - 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. [API Development](/categories/api)
4. /
5. tamayo/stretchy

ActiveLibrary[API Development](/categories/api)

tamayo/stretchy
===============

Elastic Search integration for Laravel 5.0

2.0.0(9y ago)46854[1 issues](https://github.com/ErickTamayo/Stretchy/issues)PHPPHP &gt;=5.4.0

Since Jan 27Pushed 9y ago4 watchersCompare

[ Source](https://github.com/ErickTamayo/Stretchy)[ Packagist](https://packagist.org/packages/tamayo/stretchy)[ RSS](/packages/tamayo-stretchy/feed)WikiDiscussions 2.0.1 Synced today

READMEChangelogDependencies (4)Versions (6)Used By (0)

Stretchy
========

[](#stretchy)

[![Build Status](https://camo.githubusercontent.com/b2ed8e719f1668c0f0218d1873fcc944e5f02bf9fcc3da970514ffc2d9d894dd/68747470733a2f2f7472617669732d63692e6f72672f457269636b54616d61796f2f53747265746368792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ErickTamayo/Stretchy)

Stretchy in an [Elasticsearch](http://www.elasticsearch.org/) integration for Laravel 5.

Heavily Inspired by Query Builder and Schema of laravel.

Description on going.

### Version

[](#version)

2.0.0 - Alpha

### Documentation

[](#documentation)

The current documentation is at [stretchy.readthedocs.org](http://stretchy.readthedocs.org/).

\#Installation

\###Requirements

- PHP 5.5.9+

### Installing with Composer

[](#installing-with-composer)

1. In your **composer.json**, add the dependency: `"tamayo/stretchy": "2.0.0"`
2. Add the Stretchy service provider in your app.config:

```
        'Tamayo\Stretchy\StretchyServiceProvider'
```

3. Add the following aliases:

```
		'Index'    => 'Tamayo\Stretchy\Facades\Index',
		'Document' => 'Tamayo\Stretchy\Facades\Document',
		'Stretchy' => 'Tamayo\Stretchy\Facades\Stretchy'
```

4. (Optional) If you want to override the default configuration:

```
php artisan config:publish tamayo/stretchy
```

Located in your laravel config directory: **packages/tamayo/stretchy/config.php**

\##Quick Examples ####Create Index To create a basic index just do the following:

```
Index::create('foo');
```

If you want to specify shards and replicas:

```
Index::create('foo', function($index)
	{
		$index->shards(5);
		$index->replicas(1);
	});
```

\####Delete Index

```
Index::delete('foo');
```

\####Document indexing

```
Document::index('foo')
    ->type('tweet')
    ->id(13) // Optional (if not specified elastic will generate an unique id)
    ->insert([
        'username' => '@ericktamayo',
        'tweet'    => 'Hello world!'
    ]);
```

\####Update a document

```
Document::index('foo')
    ->type('tweet')
    ->id(13)
    ->update(['tweet' => 'Hello world!!!']);
```

\####Get a document

```
Document::index('foo')->type('tweet')->Id(13)->get();
```

\####Delete a document

```
Document::index('foo')->type('tweet')->Id(13)->delete();
```

\###Searching

\#####Match Query

```
Stretchy::search('foo')->match('bar', 'Stretchy')->get();
```

To provide additional parameters:

```
Stretchy::search('foo')
	->match('bar', 'baz', ['operator' => 'and', 'zero_terms_query' => 'all'])
	->get();
```

or

```
Stretchy::search('foo')
	->match('bar', 'Stretchy', function($match)
	{
		$match->operator('and');
		$match->zeroTermsQuery('all');
		$match->cutoffFrequency(0.001);
	})
	->get();
```

\#####Term Query

```
Stretchy::search('foo')->term('bar', 'baz')->get();
```

To provide additional parameters:

```
Stretchy::search('foo')->term('bar', 'baz', ['boost' => 2])->get();
```

or

```
Stretchy::search('foo')
	->term('bar', 'baz', function($term)
	{
		$term->boost(2);
	})
	->get();
```

\#####Bool Query

```
Stretchy::search('foo')
	->bool(function($query)
	{
		$query->must(function($must)
		{
			$must->match('bar', 'baz');
		});

		$query->mustNot(function($mustNot)
		{
			$mustNot->match('bar', 'qux');
		});

		$query->should(function($should)
		{
			$should->match('bar', 'bah');
		});

		$query->minimumShouldMatch(1);
	})
	->get();
```

More examples can be found in the [documentation](http://stretchy.readthedocs.org/).

### Roadmap

[](#roadmap)

- **Documentation**
- **Make the library to be independent from Laravel components**
- **PutMapping API**

\###Author Erick Tamayo -  - [@ericktamayo](http://twitter.com/ericktamayo)

### License

[](#license)

MIT

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~9 days

Total

3

Last Release

3609d ago

PHP version history (2 changes)2.0.0PHP &gt;=5.4.0

2.0.0.x-devPHP &gt;=5.5.9

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4788817?v=4)[Erick Tamayo](/maintainers/ErickTamayo)[@ErickTamayo](https://github.com/ErickTamayo)

---

Top Contributors

[![ErickTamayo](https://avatars.githubusercontent.com/u/4788817?v=4)](https://github.com/ErickTamayo "ErickTamayo (35 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tamayo-stretchy/health.svg)

```
[![Health](https://phpackages.com/badges/tamayo-stretchy/health.svg)](https://phpackages.com/packages/tamayo-stretchy)
```

###  Alternatives

[rapidez/core

Rapidez Core

1823.5k72](/packages/rapidez-core)

PHPackages © 2026

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