PHPackages                             websecret/laravel-search - 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. [Database &amp; ORM](/categories/database)
4. /
5. websecret/laravel-search

ActiveLibrary[Database &amp; ORM](/categories/database)

websecret/laravel-search
========================

Laravel Eloquent models with Elasticsearch 2

v2.1(8y ago)43421[1 issues](https://github.com/websecret/laravel-search/issues)MITPHPPHP &gt;=5.5

Since Jul 7Pushed 8y ago6 watchersCompare

[ Source](https://github.com/websecret/laravel-search)[ Packagist](https://packagist.org/packages/websecret/laravel-search)[ Docs](https://github.com/websecret/laravel-search)[ RSS](/packages/websecret-laravel-search/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (4)Versions (5)Used By (0)

Laravel-Searchable
==================

[](#laravel-searchable)

Laravel Eloquent models with Elasticsearch 2

Installation and Requirements
-----------------------------

[](#installation-and-requirements)

First, you'll need to require the package with Composer:

```
composer require websecret/laravel-search
```

Aftwards, run `composer update` from your command line.

Then, update `config/app.php` by adding an entry for the service provider.

```
'providers' => [
	// ...
	Websecret\LaravelSearchable\SearchableServiceProvider::class,
];
```

Finally, from the command line again, run `php artisan vendor:publish --provider=Websecret\LaravelSearchable\SearchableServiceProvider` to publish the default configuration file.

Updating your Eloquent Models
-----------------------------

[](#updating-your-eloquent-models)

Your models should implement Searchable's interface and use it's trait. You should also define a protected property `$searchable` with any model-specific configurations (see [Configuration](#config) below for details):

```
use Websecret\LaravelSearchable\SearchableTrait;
use Websecret\LaravelSearchable\SearchableInterface;

class Article extends Model implements SearchableInterface
{
	use SearchableTrait;

	protected $searchable = [
        //'index' => 'domain_name',
        //'type' => 'articles',
        'fields' => [
            'title' => [
                'weight' => 3,
            ],
            'content',
            'category.title' => [
                'title' => 'category',
                'weight' => 1,
            ],
        ],
        //"fuzziness" => "AUTO",
        //"prefix_length"=> 2,
        //"max_expansions"=> 100,
    ];

}
```

Searching
---------

[](#searching)

Use `search` scope to find models. Result collection will be sorted by score.

```
    $articles = Article::where('is_active', 1)->search('apple')->get();

```

Indexing
--------

[](#indexing)

Models auto indexing on `updated`, `created` and `deleted` events. You can use `$article->searchIndex();` and `$article->searchDelete();` to manually index or delete from index. Use `Article::searchDeleteAll()` to clear all index by specified model.

Config
------

[](#config)

### fuzziness

[](#fuzziness)

Fuzzy matching treats two words that are “fuzzily” similar as if they were the same word.

Of course, the impact that a single edit has on a string depends on the length of the string. Two edits to the word hat can produce mad, so allowing two edits on a string of length 3 is overkill. The fuzziness parameter can be set to AUTO, which results in the following maximum edit distances:

- `0` for strings of one or two characters
- `1` for strings of three, four, or five characters
- `2` for strings of more than five characters

Of course, you may find that an edit distance of 2 is still overkill, and returns results that don’t appear to be related. You may get better results, and better performance, with a maximum fuzziness of 1.

### prefix\_length

[](#prefix_length)

The number of initial characters which will not be “fuzzified”. This helps to reduce the number of terms which must be examined.

### max\_expansions

[](#max_expansions)

The maximum number of terms that the fuzzy query will expand to.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 60% 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 ~116 days

Total

4

Last Release

3247d ago

Major Versions

v1.0 → v2.02017-05-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/abdb67af22a253b27f7e36f79536cc87a418b0fdbeeb613ac5db0832e1fabcdd?d=identicon)[websecret](/maintainers/websecret)

---

Top Contributors

[![blaxxi](https://avatars.githubusercontent.com/u/3585723?v=4)](https://github.com/blaxxi "blaxxi (6 commits)")[![n7olkachev](https://avatars.githubusercontent.com/u/3993345?v=4)](https://github.com/n7olkachev "n7olkachev (4 commits)")

---

Tags

searchlaravelelasticsearcheloquent

### Embed Badge

![Health badge](/badges/websecret-laravel-search/health.svg)

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

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M253](/packages/cviebrock-eloquent-sluggable)[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[mehdi-fathi/eloquent-filter

Eloquent Filter adds custom filters automatically to your Eloquent Models in Laravel.It's easy to use and fully dynamic, just with sending the Query Strings to it.

450191.6k1](/packages/mehdi-fathi-eloquent-filter)

PHPackages © 2026

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