PHPackages                             honvid/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. [Search &amp; Filtering](/categories/search)
4. /
5. honvid/laravel-search

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

honvid/laravel-search
=====================

one search drivers plugin for laravel.This package provides a unified API across a variety of different full text search services

v1.0(7y ago)3201MITPHPPHP ~7.0

Since Jun 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Honvid/laravel-search)[ Packagist](https://packagist.org/packages/honvid/laravel-search)[ RSS](/packages/honvid-laravel-search/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (2)Used By (0)

laravel-search
==============

[](#laravel-search)

one search drivers plugin for laravel

This package provides a unified API across a variety of different full text search services, it just fork from [mmanos/laravel-search](https://github.com/mmanos/laravel-search), and update the [Elasticsearch](http://www.elasticsearch.org/) to `^6.0`. It currently supports drivers for [Elasticsearch](http://www.elasticsearch.org/), [Algolia](https://www.algolia.com/).

Installation Via Composer
-------------------------

[](#installation-via-composer)

install the package by this:

```
composer require honvid/laravel-search
```

After that, you should add the service provider:

> It supports Package Auto Discovery. If your Laravel version is above 5.5, please skip this step.

Add the service provider to `app/config/app.php`, within the `providers` array.

```
'providers' => array(
	// ...
	'Honvid\Providers\SearchServiceProvider',
)
```

Add a class alias to `app/config/app.php`, within the `aliases` array.

```
'aliases' => array(
	// ...
	'Search' => 'Honvid\Facades\Search',
)
```

Configuration
-------------

[](#configuration)

Publish the default config file to your application so you can make modifications.

```
$ php artisan vendor:publish --provider="Honvid\Providers\SearchServiceProvider"
```

#### Dependencies

[](#dependencies)

The following dependencies are needed for the listed search drivers:

- Elasticsearch: `elasticsearch/elasticsearch`
- Algolia: `algolia/algoliasearch-client-php`

#### Default Index

[](#default-index)

This package provides a convenient syntax for working with a "default" index. Edit the `default_index` field in the config file to change this value. If you need to work with more than one index, see *Working With Multiple Indicies* below.

Indexing Operations
-------------------

[](#indexing-operations)

Indexing is very easy with this package. Simply provide a unique identifier for the document and an associative array of fields to index.

The index will be **created automatically** if it does not exist the first time you access it.

#### Index A Document

[](#index-a-document)

Add a document to the "default" index with an `id` of "1".

```
Search::insert(1, array(
	'title' => 'My title',
	'content' => 'The quick brown fox...',
	'status' => 'published',
));
```

> **Note:** `id` may be a string or an integer. This id is used to delete records and is also returned in search results.

#### Store Extra Parameters With A Document

[](#store-extra-parameters-with-a-document)

You may store extra parameters with a document so they can be retrieved at a later point from search results. This can be useful for referencing timestamps or other record identifiers.

```
Search::insert(
	"post-1",
	array(
		'title' => 'My title',
		'content' => 'The quick brown fox...',
		'status' => 'published',
	),
	array(
		'created_at' => time(),
		'creator_id' => 5,
	)
);
```

> **Note:** Extra parameters are not indexed but are stored in the index for future retrieval.

#### Delete A Document

[](#delete-a-document)

Delete a document from the "default" index with an `id` of "1":

```
Search::delete(1);
```

#### Delete An Index

[](#delete-an-index)

```
Search::deleteIndex();
```

Search Operations
-----------------

[](#search-operations)

#### Search For A Document

[](#search-for-a-document)

Search the "default" index for documents who's `content` field contains the word "fox":

```
$results = Search::search('content', 'fox')->get();
```

#### Search More Than One Field

[](#search-more-than-one-field)

```
$results = Search::search(array('title', 'content'), 'fox')->get();
```

#### Search All Fields

[](#search-all-fields)

```
$results = Search::search(null, 'fox')->get();
```

#### Perform A Fuzzy Search

[](#perform-a-fuzzy-search)

Perform a fuzzy search to find results with similar, but not exact, spelling. For example, you want to return documents containing the word "updates" by searching for the word "update":

```
$results = Search::search('content', 'update', array('fuzzy'=>true))->get();
```

> **Note:** You may also pass a numeric value between 0 and 1 for the fuzzy parameter, where a value closer to 1 requires a higher similarity. Defaults to 0.5.

#### Apply A Filter To Your Query

[](#apply-a-filter-to-your-query)

You can apply filters to your search queries as well. Filters attempt to match the value you specify as an entire "phrase".

```
$results = Search::search('content', 'fox')
	->where('status', 'published')
	->get();
```

> **Note:** Filters do not guarantee an exact match of the entire field value if the value contains multiple words.

#### Geo-Search

[](#geo-search)

Some drivers support location-aware searching:

```
$results = Search::search('content', 'fox')
	->whereLocation(36.16781, -96.023561, 10000)
	->get();
```

Where the parameters are `latitude`, `longitude`, and `distance` (in meters).

> **Note:** Currently, only the `algolia` driver supports geo-searching. Ensure each indexed record contains the location information: `_geoloc => ['lat' => 1.23, 'lng' => 1.23]`.

#### Limit Your Result Set

[](#limit-your-result-set)

```
$results = Search::search('content', 'fox')
	->where('status', 'published')
	->limit(10) // Limit 10
	->get();

$results = Search::search('content', 'fox')
	->where('status', 'published')
	->limit(10, 30) // Limit 10, offset 30
	->get();
```

#### Paginate Your Result Set

[](#paginate-your-result-set)

You can also paginate your result set using a Laravel paginator instance.

```
$paginator = Search::search('content', 'fox')->paginate(15);
```

#### Limit The Fields You Want Back From The Response

[](#limit-the-fields-you-want-back-from-the-response)

```
$results = Search::select('id', 'created_at')
	->search('content', 'fox')
	->get();
```

#### Chain Multiple Searches And Filters

[](#chain-multiple-searches-and-filters)

```
$results = Search::select('id', 'created_at')
	->where('title', 'My title')
	->where('status', 'published')
	->search('content', 'fox')
	->search('content', 'quick')
	->limit(10)
	->get();
```

> **Note:** Chained filters/searches are constructed as boolean queries where each **must** provide a match.

#### Delete All Documents That Match A Query

[](#delete-all-documents-that-match-a-query)

```
Search::search('content', 'fox')->delete();
```

Working With Multiple Indicies
------------------------------

[](#working-with-multiple-indicies)

If you need to work with more than one index, you may access all of the same methods mentioned above after you specify the index name.

Add a document to an index called "posts":

```
Search::index('posts')->insert(1, array(
	'title' => 'My title',
	'content' => 'The quick brown fox...',
	'status' => 'published',
));
```

Search the "posts" index for documents who's `content` field contains the word "fox" and who's `status` is "published":

```
$results = Search::index('posts')->search('content', 'fox')
	->where('status', 'published')
	->get();
```

Delete a document from the "posts" index with an `id` of "1":

```
Search::index('posts')->delete(1);
```

Delete the entire "posts" index:

```
Search::index('posts')->deleteIndex();
```

Advanced Query Callbacks
------------------------

[](#advanced-query-callbacks)

If you need more control over a search query you may add a callback function which will be called after all conditions have been added to the query but before the query has been executed. You can then make changes to the native query instance and return it to be executed.

```
$results = Search::index('posts')->select('id', 'created_at')
	->search('content', 'fox')
	->addCallback(function ($query) {
		// Make changes to $query...
		return $query;
	})
	->get();
```

Since each driver has it's own native `$query` object/array, you may only want to execute your callback for one of the drivers:

```
$results = Search::index('posts')->select('id', 'created_at')
	->search('content', 'fox')
	->addCallback(function ($query) {
		// Adjust pagination for an elasticsearch query array.
		$query['from'] = 0;
		$query['size'] = 20;
		return $query;
	}, 'elasticsearch')
	->get();
```

> **Note:** You may also pass an array of drivers as the second parameter.

License
-------

[](#license)

The Laravel-Search package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

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

Unknown

Total

1

Last Release

2892d ago

### Community

Maintainers

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

---

Top Contributors

[![Honvid](https://avatars.githubusercontent.com/u/8649968?v=4)](https://github.com/Honvid "Honvid (1 commits)")

---

Tags

searchlaravelelasticsearchalgoliaindex

### Embed Badge

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

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

###  Alternatives

[mailerlite/laravel-elasticsearch

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

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[algolia/scout-extended

Scout Extended extends Laravel Scout adding algolia-specific features

4186.3M6](/packages/algolia-scout-extended)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

397612.3k](/packages/jeroen-g-explorer)[mmanos/laravel-search

A search package for Laravel 5.

36475.7k1](/packages/mmanos-laravel-search)[algolia/laravel-scout-settings

Import/Export Algolia settings into your Laravel Scout project

23396.9k](/packages/algolia-laravel-scout-settings)[gtk/larasearch

A driver based solution to searching your Eloquent models supports Laravel 5.2 and Elasticsearch engine.

133.9k](/packages/gtk-larasearch)

PHPackages © 2026

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