PHPackages                             swisnl/laravel-fulltext - 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. swisnl/laravel-fulltext

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

swisnl/laravel-fulltext
=======================

Fulltext indexing and searching for Laravel

0.23.2(2mo ago)184104.5k↑21.5%24[2 issues](https://github.com/swisnl/laravel-fulltext/issues)[3 PRs](https://github.com/swisnl/laravel-fulltext/pulls)6MITPHPPHP ^8.1CI passing

Since Nov 7Pushed 2mo ago8 watchersCompare

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

READMEChangelog (10)Dependencies (14)Versions (32)Used By (6)

Laravel fulltext index and search
=================================

[](#laravel-fulltext-index-and-search)

[![Latest Version on Packagist](https://camo.githubusercontent.com/631eee7acd566a03440aa0d460970b128674eb8edd483f86e001978ae3f41b0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737769736e6c2f6c61726176656c2d66756c6c746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/swisnl/laravel-fulltext)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Buy us a tree](https://camo.githubusercontent.com/cec0a9b35a1c3235bdbe0d13ea8fbd866a23e30280ad6ca27078c1fd4ac1b709/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d6c69676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://plant.treeware.earth/swisnl/laravel-fulltext)[![Build Status](https://camo.githubusercontent.com/6fcf9de255c401246bef4e7e95d3fc7b0c14d431b4aca303c0fbefaa1067ed2b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769736e6c2f6c61726176656c2d66756c6c746578742f72756e2d74657374732e796d6c3f6c6162656c3d7465737473266272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/swisnl/laravel-fulltext/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/2512b9c20e91f57dd90550cf096d11e69e522670e9007fef75fc4909706215d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737769736e6c2f6c61726176656c2d66756c6c746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/swisnl/laravel-fulltext)[![Made by SWIS](https://camo.githubusercontent.com/ef6bdd6ab8d4f47bceb74dcf558b0915c6b419cbba320096324af0518e43091d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2546302539462539412538302d6d6164652532306279253230535749532d2532333037333741392e7376673f7374796c653d666c61742d737175617265)](https://www.swis.nl)

This package creates a MySQL fulltext index for models and enables you to search through those.

Install
-------

[](#install)

1. Install with composer `composer require swisnl/laravel-fulltext`
2. Publish migrations and config `php artisan vendor:publish --tag=laravel-fulltext`
3. Migrate the database `php artisan migrate`

Usage
-----

[](#usage)

The package uses a model observer to update the index when models change. If you want to run a full index you can use the console commands.

### Models

[](#models)

Add the `Indexable` trait to the model you want to have indexed and define the columns you'd like to index as title and content.

#### Example

[](#example)

```
class Country extends Model
{

    use \Swis\Laravel\Fulltext\Indexable;

    protected $indexContentColumns = ['biographies.name', 'political_situation', 'elections'];
    protected $indexTitleColumns = ['name', 'governmental_type'];

}
```

You can use a dot notation to query relationships for the model, like `biographies.name`.

### Searching

[](#searching)

You can search using the Search class.

```
$search = new \Swis\Laravel\Fulltext\Search();
$search->run('europe');
```

This will return a Collection of `\Swis\Laravel\Fulltext\IndexedRecord` which contain the models in the Polymorphic relation `indexable`.

If you only want to search a certain model you can use `$search->runForClass('europe', Country::class);`. This will only return results from that model.

### Artisan Commands

[](#artisan-commands)

#### laravel-fulltext:all

[](#laravel-fulltextall)

Index all models for a certain class.

```
php artisan laravel-fulltext:all \\App\\Models\\Country
```

#### laravel-fulltext:one

[](#laravel-fulltextone)

Index a single model of a certain class.

```
php artisan laravel-fulltext:one \\App\\Models\\Country 4
```

Options
-------

[](#options)

### db\_connection

[](#db_connection)

Choose the database connection to use, defaults to the default database connection. When you are NOT using the default database connection, this MUST be set before running the migration to work correctly.

### weight.title weight.content

[](#weighttitle-weightcontent)

Results on `title` or `content` are weighted in the results. Search result score is multiplied by the weight in this config.

### enable\_wildcards

[](#enable_wildcards)

Enable wildcard after words. So when searching for example `car` it will also match `carbon`.

### exclude\_feature\_enabled

[](#exclude_feature_enabled)

This feature excludes some rows from being returned. Enable this when you have a flag in your model which determines whether this record must be returned in search queries or not. By default this feature is disabled.

### exclude\_records\_column\_name

[](#exclude_records_column_name)

The column name for that property (which acts as a flag). This must match the exact column name at the table.

#### An example of using this feature

[](#an-example-of-using-this-feature)

If you have a blog and then added this search functionality to your blog to search through your blog posts. Sometimes you do not want some posts to appear in the search result, for example when a post is not published yet. This feature helps you to do it.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Björn Brala](https://github.com/swisnl)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/swisnl/laravel-fulltext) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

SWIS ❤️ Open Source
-------------------

[](#swis-heart-open-source)

[SWIS](https://www.swis.nl) is a web agency from Leiden, the Netherlands. We love working with open source software.

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance86

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 58.9% 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 ~121 days

Recently: every ~373 days

Total

29

Last Release

66d ago

PHP version history (6 changes)0.1.1PHP &gt;=5.6

0.14.0PHP &gt;=7.0

0.16.0PHP &gt;=7.1.3

0.21.0PHP &gt;=7.2

0.22.0PHP ^7.4|^8.0

0.23.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8734305?v=4)[SWIS](/maintainers/swisnl)[@swisnl](https://github.com/swisnl)

---

Top Contributors

[![JaZo](https://avatars.githubusercontent.com/u/3475007?v=4)](https://github.com/JaZo "JaZo (93 commits)")[![bbrala](https://avatars.githubusercontent.com/u/3294970?v=4)](https://github.com/bbrala "bbrala (35 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (8 commits)")[![samberrry](https://avatars.githubusercontent.com/u/20775532?v=4)](https://github.com/samberrry "samberrry (6 commits)")[![vblinden](https://avatars.githubusercontent.com/u/1420356?v=4)](https://github.com/vblinden "vblinden (5 commits)")[![bingvanmoorsel](https://avatars.githubusercontent.com/u/4376490?v=4)](https://github.com/bingvanmoorsel "bingvanmoorsel (3 commits)")[![marijnz0r](https://avatars.githubusercontent.com/u/12230678?v=4)](https://github.com/marijnz0r "marijnz0r (2 commits)")[![PrinsFrank](https://avatars.githubusercontent.com/u/25006490?v=4)](https://github.com/PrinsFrank "PrinsFrank (2 commits)")[![hpacleb](https://avatars.githubusercontent.com/u/24486552?v=4)](https://github.com/hpacleb "hpacleb (1 commits)")[![RoachMech](https://avatars.githubusercontent.com/u/7983727?v=4)](https://github.com/RoachMech "RoachMech (1 commits)")[![barryatswisnl](https://avatars.githubusercontent.com/u/18284224?v=4)](https://github.com/barryatswisnl "barryatswisnl (1 commits)")[![mattdinthehouse](https://avatars.githubusercontent.com/u/6799224?v=4)](https://github.com/mattdinthehouse "mattdinthehouse (1 commits)")

---

Tags

hacktoberfestswisnllaravel-fulltext

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/swisnl-laravel-fulltext/health.svg)

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

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)

PHPackages © 2026

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