PHPackages                             mattkingshott/quest - 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. mattkingshott/quest

Abandoned → [caneara/quest](/?search=caneara%2Fquest)ArchivedLibrary[Search &amp; Filtering](/categories/search)

mattkingshott/quest
===================

A package that provides pseudo fuzzy-searching to Laravel database queries.

v4.0.0(2y ago)110100.7k↓34.4%16MITPHPPHP ^7.4|^8.0

Since Apr 14Pushed 2y ago4 watchersCompare

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

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

Quest
=====

[](#quest)

This package enables pseudo fuzzy-searching within Laravel database and Eloquent queries. Due to its pattern matching methods, it only supports **MySQL** or **MariaDB**, though I welcome any PRs to enable support for databases like Postgres.

Much of this library is based on the fantastic work of Tom Lingham for the now abandoned [Laravel Searchy](https://github.com/TomLingham/Laravel-Searchy) package. If you're interested in the background of how the fuzzy searching works, check out the readme for that project.

Installation
------------

[](#installation)

Pull in the package using composer

```
composer require caneara/quest
```

Usage
-----

[](#usage)

Quest automatically registers a service provider containing several macros. These macros are then attached to the underlying `Illuminate\Database\Query\Builder` class.

### Filtering results

[](#filtering-results)

You can perform a fuzzy-search by calling the `whereFuzzy` method. This method takes two parameters. The first, is the field name. The second, is the value to use for the search e.g.

```
DB::table('users')
  ->whereFuzzy('name', 'jd') // matches John Doe
  ->first();

User::whereFuzzy('name', 'jd') // matches John Doe
    ->first();
```

You can also perform a fuzzy search across multiple columns by chaining several `whereFuzzy` method calls:

```
User::whereFuzzy('name', 'jd')  // matches John Doe
    ->whereFuzzy('email', 'gm') // matches @gmail.com
    ->first();
```

You can also perform searches across multiple columns using `orWhereFuzzy` method calls:

```
User::whereFuzzy(function ($query) {
    $query->orWhereFuzzy('name', 'jd'); // matches John Doe
    $query->orWhereFuzzy('email', 'gm'); // matches @gmail.com
})->first();
```

### Ordering results

[](#ordering-results)

When using Quest, a `'fuzzy_relevance_*'` column will be included in your search results. The `*` is a wildcard that will be replaced with the name of the field that you are searching on e.g.

```
User::whereFuzzy('email', 'gm') // fuzzy_relevance_email
```

This column contains the score that the record received after each of the fuzzy-searching pattern matchers were applied to it. The higher the score, the more closely the record matches the search term.

Of course, you'll want to order the results so that the records with the highest score appear first. To make this easier, Quest includes an `orderByFuzzy` helper method that wraps the relevant `orderBy` clauses:

```
User::whereFuzzy('name', 'jd')
    ->orderByFuzzy('name')
    ->first();

// Equivalent to:

User::whereFuzzy('name', 'jd')
    ->orderBy('fuzzy_relevance_name', 'desc')
    ->first();
```

If you are searching across multiple fields, you can provide an `array` to the `orderByFuzzy` method:

```
User::whereFuzzy('name', 'jd')
    ->whereFuzzy('email', 'gm')
    ->orderByFuzzy(['name', 'email'])
    ->first();

// Equivalent to:

User::whereFuzzy('name', 'jd')
    ->orderBy('fuzzy_relevance_name', 'desc')
    ->orderBy('fuzzy_relevance_email', 'desc')
    ->first();
```

### Applying a minimum threshold

[](#applying-a-minimum-threshold)

When using Quest, an overall score will be assigned to each record within the `_fuzzy_relevance_` column. This score is represented as an `integer` between 0 and 295.

> Note that the `fuzzy_relevance` score is not divided by the number of columns. Therefore, it could be up to, for example, 590 if two fields match exactly.

You can enforce a minimum score to restrict the results by using the `withMinimumRelevance()` method. Setting a higher score will return fewer, but likely more-relevant results.

```
// Before
User::whereFuzzy('name', 'jd')
    ->having('_fuzzy_relevance_', '>',  70)
    ->first();

// After
User::whereFuzzy('name', 'jd')
    ->withMinimumRelevance(70)
    ->first();
```

When using `orWhereFuzzy` include the minimum relevance as an optional third parameter

```
// Returns results which exceed 70 on the name column or 90 on the email column
User::whereFuzzy(function ($query) {
    $query->orWhereFuzzy('name', 'jd', 70);
    $query->orWhereFuzzy('email', 'gm', 90);
})->get();
```

### Performance (large datasets)

[](#performance-large-datasets)

When searching large tables to only confirm whether matches exist, removing sorting and relevance checking will significantly increase query performance. To do this, simply supply `false` as a third parameter for the `whereFuzzy` or `orWhereFuzzy` methods:

```
DB::table('users')
  ->whereFuzzy('name', 'jd', false)
  ->orWhereFuzzy('name', 'gm', 0, false);
  ->first();
```

To adjust the relevance threshold you can filter the relevance data manually if needed.

You can also further improve performance by selectively disabling one or more pattern matchers. Simply supply an `array` of pattern matchers you want to disable as the fourth parameter e.g.

```
DB::table('users')
  ->whereFuzzy('name', 'jd', true, [
    'AcronymMatcher',
    'StudlyCaseMatcher',
  ]);
  ->first();
```

The following pattern matchers can be included in the `array`:

- ExactMatcher
- StartOfStringMatcher
- AcronymMatcher
- ConsecutiveCharactersMatcher
- StartOfWordsMatcher
- StudlyCaseMatcher
- InStringMatcher
- TimesInStringMatcher

Review the `/src/Matchers` directory to see what each matcher does for a query.

Limitations
-----------

[](#limitations)

It is not possible to use the `paginate` method with Quest as the relevance fields are omitted from the secondary query that Laravel runs to get the count of the records required for `LengthAwarePaginator`. However, you can use the `simplePaginate` method without issue. In many cases this a more preferable option anyway, particularly when dealing with large datasets as the `paginate` method becomes slow when scrolling through large numbers of pages.

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

[](#contributing)

Thank you for considering a contribution to Quest. You are welcome to submit a PR containing improvements, however if they are substantial in nature, please also be sure to include a test or tests.

License
-------

[](#license)

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

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 60.4% 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 ~104 days

Recently: every ~166 days

Total

13

Last Release

971d ago

Major Versions

v1.1.1 → v2.0.02021-11-22

v2.0.2 → v3.0.02023-04-18

v3.0.0 → v4.0.02023-09-21

PHP version history (2 changes)v1.0.0PHP ^7.4

1.0.5PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/22bc3f376c7511f4fc85e2c240cf52c075c491426795c71409c0a4b551a8bf85?d=identicon)[mattkingshott](/maintainers/mattkingshott)

---

Top Contributors

[![mattkingshott](https://avatars.githubusercontent.com/u/51963402?v=4)](https://github.com/mattkingshott "mattkingshott (64 commits)")[![pbringetto](https://avatars.githubusercontent.com/u/50182684?v=4)](https://github.com/pbringetto "pbringetto (34 commits)")[![dark4ce](https://avatars.githubusercontent.com/u/4579282?v=4)](https://github.com/dark4ce "dark4ce (3 commits)")[![Minhyme](https://avatars.githubusercontent.com/u/37751220?v=4)](https://github.com/Minhyme "Minhyme (2 commits)")[![NabeelYousafPasha](https://avatars.githubusercontent.com/u/46818315?v=4)](https://github.com/NabeelYousafPasha "NabeelYousafPasha (1 commits)")[![brandonbest](https://avatars.githubusercontent.com/u/7060471?v=4)](https://github.com/brandonbest "brandonbest (1 commits)")[![robertmarney](https://avatars.githubusercontent.com/u/48888686?v=4)](https://github.com/robertmarney "robertmarney (1 commits)")

---

Tags

phpsearchlaravelfuzzyquest

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mattkingshott-quest/health.svg)

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

###  Alternatives

[rap2hpoutre/similar-text-finder

Fuzzy Search, similar text finder: "Did you mean `foo` ?"

13877.7k3](/packages/rap2hpoutre-similar-text-finder)[omaressaouaf/query-builder-criteria

Define reusable query criteria for filtering, sorting, search, field selection, and includes in Laravel Eloquent models

282.4k](/packages/omaressaouaf-query-builder-criteria)

PHPackages © 2026

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