{"id":13593704,"url":"https://github.com/caneara/quest","last_synced_at":"2026-01-14T01:37:09.091Z","repository":{"id":40586772,"uuid":"255572342","full_name":"caneara/quest","owner":"caneara","description":"A pseudo fuzzy-searching library for Laravel database queries.","archived":true,"fork":false,"pushed_at":"2023-09-21T07:25:19.000Z","size":347,"stargazers_count":110,"open_issues_count":0,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-29T06:26:59.852Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caneara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/migrations/2014_10_12_000000_create_users_table.php","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-14T09:57:20.000Z","updated_at":"2025-04-23T07:57:22.000Z","dependencies_parsed_at":"2024-06-19T05:25:37.937Z","dependency_job_id":"d0acd8ba-7e3a-447b-96be-956fde01f4e7","html_url":"https://github.com/caneara/quest","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/caneara/quest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caneara%2Fquest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caneara%2Fquest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caneara%2Fquest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caneara%2Fquest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caneara","download_url":"https://codeload.github.com/caneara/quest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caneara%2Fquest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T16:01:23.354Z","updated_at":"2026-01-14T01:37:09.074Z","avatar_url":"https://github.com/caneara.png","language":"PHP","readme":"# Quest\n\nThis 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.\n\nMuch 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.\n\n## Installation\n\nPull in the package using composer\n\n```bash\ncomposer require caneara/quest\n```\n\n## Usage\n\nQuest automatically registers a service provider containing several macros. These macros are then attached to the underlying `Illuminate\\Database\\Query\\Builder` class.\n\n### Filtering results\n\nYou 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.\n\n```php\nDB::table('users')\n  -\u003ewhereFuzzy('name', 'jd') // matches John Doe\n  -\u003efirst();\n\nUser::whereFuzzy('name', 'jd') // matches John Doe\n    -\u003efirst();\n```\n\nYou can also perform a fuzzy search across multiple columns by chaining several `whereFuzzy` method calls:\n\n```php\nUser::whereFuzzy('name', 'jd')  // matches John Doe\n    -\u003ewhereFuzzy('email', 'gm') // matches @gmail.com\n    -\u003efirst();\n```\n\nYou can also perform searches across multiple columns using `orWhereFuzzy` method calls:\n```php\nUser::whereFuzzy(function ($query) {\n    $query-\u003eorWhereFuzzy('name', 'jd'); // matches John Doe\n    $query-\u003eorWhereFuzzy('email', 'gm'); // matches @gmail.com\n})-\u003efirst();\n```\n\n### Ordering results\n\nWhen 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.\n\n```php\nUser::whereFuzzy('email', 'gm') // fuzzy_relevance_email\n```\n\nThis 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.\n\nOf 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:\n\n```php\nUser::whereFuzzy('name', 'jd')\n    -\u003eorderByFuzzy('name')\n    -\u003efirst();\n\n// Equivalent to:\n\nUser::whereFuzzy('name', 'jd')\n    -\u003eorderBy('fuzzy_relevance_name', 'desc')\n    -\u003efirst();\n```\n\nIf you are searching across multiple fields, you can provide an `array` to the `orderByFuzzy` method:\n\n```php\nUser::whereFuzzy('name', 'jd')\n    -\u003ewhereFuzzy('email', 'gm')\n    -\u003eorderByFuzzy(['name', 'email'])\n    -\u003efirst();\n\n// Equivalent to:\n\nUser::whereFuzzy('name', 'jd')\n    -\u003eorderBy('fuzzy_relevance_name', 'desc')\n    -\u003eorderBy('fuzzy_relevance_email', 'desc')\n    -\u003efirst();\n```\n### Applying a minimum threshold\n\nWhen 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.\n\n\u003e 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.\n\nYou 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.\n\n```php\n// Before\nUser::whereFuzzy('name', 'jd')\n    -\u003ehaving('_fuzzy_relevance_', '\u003e',  70)\n    -\u003efirst();\n\n// After\nUser::whereFuzzy('name', 'jd')\n    -\u003ewithMinimumRelevance(70)\n    -\u003efirst();\n```\n\nWhen using `orWhereFuzzy` include the minimum relevance as an optional third parameter\n\n```php\n// Returns results which exceed 70 on the name column or 90 on the email column\nUser::whereFuzzy(function ($query) {\n    $query-\u003eorWhereFuzzy('name', 'jd', 70);\n    $query-\u003eorWhereFuzzy('email', 'gm', 90);\n})-\u003eget();\n```\n\n### Performance (large datasets)\n\nWhen 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:\n\n```php\nDB::table('users')\n  -\u003ewhereFuzzy('name', 'jd', false) \n  -\u003eorWhereFuzzy('name', 'gm', 0, false);\n  -\u003efirst();\n```\n\nTo adjust the relevance threshold you can filter the relevance data manually if needed.\n\nYou 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.\n\n```php\nDB::table('users')\n  -\u003ewhereFuzzy('name', 'jd', true, [\n    'AcronymMatcher',\n    'StudlyCaseMatcher',\n  ]);\n  -\u003efirst();\n```\n\nThe following pattern matchers can be included in the `array`:\n\n- ExactMatcher\n- StartOfStringMatcher\n- AcronymMatcher\n- ConsecutiveCharactersMatcher\n- StartOfWordsMatcher\n- StudlyCaseMatcher\n- InStringMatcher\n- TimesInStringMatcher\n\nReview the `/src/Matchers` directory to see what each matcher does for a query.\n\n## Limitations\n\nIt 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.\n\n## Contributing\n\nThank 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.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaneara%2Fquest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaneara%2Fquest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaneara%2Fquest/lists"}