PHPackages                             shabushabu/laravel-paradedb-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. shabushabu/laravel-paradedb-search

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

shabushabu/laravel-paradedb-search
==================================

Integrates the pg\_search extension by ParadeDB into Laravel

v0.12.1(6mo ago)141.9k↓56.9%[1 issues](https://github.com/ShabuShabu/laravel-paradedb-search/issues)MITPHPPHP ^8.2

Since Jun 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/ShabuShabu/laravel-paradedb-search)[ Packagist](https://packagist.org/packages/shabushabu/laravel-paradedb-search)[ Docs](https://github.com/ShabuShabu/laravel-paradedb-search)[ GitHub Sponsors](https://github.com/boris-glumpler)[ RSS](/packages/shabushabu-laravel-paradedb-search/feed)WikiDiscussions develop Synced 2d ago

READMEChangelogDependencies (16)Versions (19)Used By (0)

[![ParadeDB Search for Laravel](laravel-paradedb-search.png)](laravel-paradedb-search.png)

ParadeDB Search for Laravel
===========================

[](#paradedb-search-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c0711dd654857e9d0818a4be57c49cce008ed2e7cb0132e3ae33973db26d8c4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736861627573686162752f6c61726176656c2d70617261646564622d7365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/shabushabu/laravel-paradedb-search)[![Total Downloads](https://camo.githubusercontent.com/2fc179f677fedf4f6d1e057150396529b757ac8b3e2af5dcd05f311679380beb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736861627573686162752f6c61726176656c2d70617261646564622d7365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/shabushabu/laravel-paradedb-search)

Integrates the `pg_search` Postgres extension by [ParadeDB](https://docs.paradedb.com/search/quickstart) into [Laravel](https://laravel.com)

Supported minimum versions
--------------------------

[](#supported-minimum-versions)

PHPLaravelPostgreSQLpg\_search8.412.017.00.22.0Installation
------------

[](#installation)

Caution

Please note that this is a fairly new package and, even though it is well tested, it should be considered pre-release software

Before installing this package, you should install and enable the [pg\_search](https://github.com/paradedb/paradedb/tree/dev/pg_search) extension.

You can then install the package via composer:

```
composer require shabushabu/laravel-paradedb-search
```

You can also publish the config file:

```
php artisan vendor:publish --tag="paradedb-search-config"
```

These are the contents of the published config file:

```
return [
    'index_suffix' => env('PG_SEARCH_INDEX_SUFFIX', 'idx'),
    'highlighting_tag' => env('PG_SEARCH_HIGHLIGHTING_TAG', ''),
    'remove_scopes' => [
        'fallback' => null,
    ],
];
```

Usage
-----

[](#usage)

This is the documentation for the upcoming v1.0 release (develop branch). The documentation for the v1 API can be found [here](V1.md). Please note that the v2 API should be used **wherever possible**!

It is recommended to first familiarize yourself with the [extension docs](https://docs.paradedb.com/welcome/introduction) as most of the examples found there translate directly to the expressions used in this package!

### Operators

[](#operators)

The operators supported by `pg_search` are already registered for you automatically. Additionally, we also register all supported `pgvector` operators.

Please see the following enums

- `\ShabuShabu\ParadeDB\Operators\FullText`
- `\ShabuShabu\ParadeDB\Operators\Distance`

### Creating an index

[](#creating-an-index)

A `bm25` index can be created like this in a migration:

```
use ShabuShabu\ParadeDB\Expressions\v2\Tokenizers\UnicodeWords;

$table->bm25(
    columns: [
        'id',
        (new UnicodeWords('name'))->removeEmojis(),
        'description',
    ],
);
```

If the `key_field` is anything other than `id`, then you can specify it in the second argument together with any other parameters you might need:

```
$table->bm25(
    columns: ['id', 'description'],
    parameters: ['key_field' => 'uuid'],
);
```

The following tokenizers are currently supported under this namespace: `\ShabuShabu\ParadeDB\Expressions\v2\Tokenizers`.

- `ChineseCompatible`
- `ICU`
- `Jieba`
- `Lindera`
- `Literal`
- `LiteralNormalized`
- `Ngram`
- `RegexPattern`
- `Simple`
- `SourceCode`
- `UnicodeWords`
- `Whitespace`

Please refer to the [pg\_search docs](https://docs.paradedb.com/documentation/tokenizers/overview) for more information.

#### Composite types

[](#composite-types)

If you have more than 32 columns to index, then you will need to create a composite type in a migration:

```
Schema::createCompositeType('item_fields', [
    new Literal('name'),
    'description text',
    new Type('category', 'text'),
]);
```

You can use this type in your index like this:

```
use ShabuShabu\ParadeDB\Expressions\v2\Casts\Row;

$table->bm25(
    columns: [
        new Row('item_fields', ['name', 'description', 'category'])
    ]
);
```

### Starting your search

[](#starting-your-search)

It is recommended to always start your search using the available `search` macro like so:

```
Product::search()
    ->where('description', '@@@', 'shoes')
    ->get();
```

This macro will automatically remove any global scopes that are registered in the config file as most of these will prevent the `bm25` index from being used.

This macro might also be used for other purposes in the future.

### Advanced query functions

[](#advanced-query-functions)

See the relevant documentation for the [pg\_search docs](https://docs.paradedb.com/documentation/query-builder/overview).

#### All

[](#all)

```
use ShabuShabu\ParadeDB\Expressions\v2\All;

Product::search()
    ->where('id', '@@@', new All())
    ->get();
```

#### More like this

[](#more-like-this)

```
use ShabuShabu\ParadeDB\Expressions\v2\MoreLikeThis;

Product::search()
    ->where('id', '@@@', new MoreLikeThis(3))
    ->get();
```

#### Phrase prefix

[](#phrase-prefix)

```
use ShabuShabu\ParadeDB\Expressions\v2\PhrasePrefix;

Product::search()
    ->where('description', '@@@', new PhrasePrefix(['running', 'sh']))
    ->get();
```

#### Query parser

[](#query-parser)

```
use ShabuShabu\ParadeDB\Expressions\v2\Parse;

Product::search()
    ->where('description', '@@@', new Parse('description:(sleek shoes) AND rating:>3'))
    ->get();
```

The `Parse` expression also accepts a TantivyQL query builder (see below).

#### Range term

[](#range-term)

```
use ShabuShabu\ParadeDB\Expressions\v2\RangeTerm;

Product::search()
    ->where('weight_range', '@@@', new RangeTerm(1))
    ->get();
```

The `RangeTerm` expression also accepts a `ShabuShabu\ParadeDB\Expressions\Ranges\RangeExpression`.

#### Regex

[](#regex)

```
use ShabuShabu\ParadeDB\Expressions\v2\Regex;

Product::search()
    ->where('description', '@@@', new Regex('key.*'))
    ->get();
```

#### Regex phrase

[](#regex-phrase)

```
use ShabuShabu\ParadeDB\Expressions\v2\RegexPhrase;

Product::search()
    ->where('description', '@@@', new RegexPhrase(['ru.*', 'shoes']))
    ->get();
```

### Aggregates

[](#aggregates)

Various aggregates can be retrieved using the `bm25` index, like counts. Please see the [pg\_search docs](https://docs.paradedb.com/documentation/aggregates/overview) for more information.

```
use ShabuShabu\ParadeDB\Expressions\v2\All;
use ShabuShabu\ParadeDB\Expressions\v2\Agg;

Product::search()
    ->select(new Agg([
        'value_count' => ['field' => 'id'],
    ]))
    ->where('id', '@@@', new All)
    ->agg();
```

The `agg` macro will return a collection of results, with the aggregate values already decoded.

By default, only the `agg` key will be decoded. If you requested multiple aggregates or aliased the column to something else, then you can specify the keys like so:

```
use ShabuShabu\ParadeDB\Expressions\v2\All;
use ShabuShabu\ParadeDB\Expressions\v2\Agg;
use Tpetry\QueryExpressions\Language\Alias;

Product::search()
    ->select([
        new Alias(new Agg(...), 'first'),
        new Alias(new Agg(...), 'second')
    ])
    ->where('id', '@@@', new All)
    ->agg(['first', 'second']);
```

### TantivyQL

[](#tantivyql)

ParadeDB Search for Laravel comes with a fluent builder for TantivyQL, a simple string-based query language.

This builder can be used within various v1 ParadeDB as well as the v2 `Parse` expressions.

### Basic query

[](#basic-query)

```
use ShabuShabu\ParadeDB\TantivyQL\Query;

Query::string()->where('description', 'keyboard')->get();

// results in: description:keyboard
```

### Add an IN condition

[](#add-an-in-condition)

```
Query::string()
    ->where('description', ['keyboard', 'toy'])
    ->get();

// results in: description:IN [keyboard, toy]
```

### Add an AND NOT condition

[](#add-an-and-not-condition)

```
(string) Query::string()
    ->where('category', 'electronics')
    ->whereNot('description', 'keyboard');

// results in: category:electronics AND NOT description:keyboard
```

### Boost a condition

[](#boost-a-condition)

```
Query::string()
    ->where('description', 'keyboard', boost: 1)
    ->get();

// results in: description:keyboard^1
```

### Apply the slop operator

[](#apply-the-slop-operator)

```
Query::string()
    ->where('description', 'ergonomic keyboard', slop: 1)
    ->get();

// results in: description:"ergonomic keyboard"~1
```

### More complex example with a sub condition

[](#more-complex-example-with-a-sub-condition)

```
Query::string()
    ->where('description', ['keyboard', 'toy'])
    ->where(
        fn (Builder $builder) => $builder
            ->where('category', 'electronics')
            ->orWhere('tag', 'office')
    )
    ->get();

// results in: description:IN [keyboard, toy] AND (category:electronics OR tag:office)
```

### Apply a simple filter

[](#apply-a-simple-filter)

```
use ShabuShabu\ParadeDB\TantivyQL\Operators\Filter;

Query::string()
    ->whereFilter('rating', Filter::equals, 4)
    ->get();

// results in: rating:4
```

### Apply a boolean filter

[](#apply-a-boolean-filter)

```
Query::string()
    ->whereFilter('is_available', '=', false)
    ->get();

// results in: is_available:false
```

### Apply a basic range filter

[](#apply-a-basic-range-filter)

```
Query::string()
    ->whereFilter('rating', '>', 4)
    ->get();

// results in: rating:>4
```

### Apply an inclusive range filter

[](#apply-an-inclusive-range-filter)

```
use ShabuShabu\ParadeDB\TantivyQL\Operators\Range;

Query::string()
    ->whereFilter('rating', Range::includeAll, [2, 5])
    ->get();

// results in: rating:[2 TO 5]
```

### Apply an exclusive range filter

[](#apply-an-exclusive-range-filter)

```
use ShabuShabu\ParadeDB\TantivyQL\Operators\Range;

Query::string()
    ->whereFilter('rating', Range::excludeAll, [2, 5])
    ->get();

// results in: rating:{2 TO 5}
```

### A word of caution

[](#a-word-of-caution)

While it is possible to combine ParadeDB queries with regular Eloquent queries, you will incur some performance penalties.

For optimal performance it is recommended to let the `bm25` index do as much work as possible!

Commands
--------

[](#commands)

This package comes with various Artisan commands to help you manage your `pg_search` instance.

### Index integrity

[](#index-integrity)

Allows you to verify a single or all indexes, as well as list your indexes and segments.

```
php artisan paradedb:integrity
```

### Test table

[](#test-table)

Either create or drop the built-in test table:

```
php artisan paradedb:test-table
```

### Tokenizers

[](#tokenizers)

List all available tokenizers:

```
php artisan paradedb:tokenizers
```

### Version info

[](#version-info)

List some versioning info:

```
php artisan paradedb:version
```

Testing
-------

[](#testing)

The tests require a PostgreSQL database, which can easily be set up by running the following script:

```
composer testdb
```

Warning

Please note that both [pg\_search](https://github.com/paradedb/paradedb/tree/dev/pg_search#installation) and [pgvector](https://github.com/pgvector/pgvector#installation) extensions need to be available already.

Then run the tests:

```
composer test
```

Or with test coverage:

```
composer test-coverage
```

Or with type coverage:

```
composer type-coverage
```

Or run PHPStan:

```
composer analyse
```

### ParadeDB test table

[](#paradedb-test-table)

There is also a command that allows you to create and drop the built-in test table

```
php artisan paradedb:test-table create
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Taylor Otwell](https://github.com/taylorotwell) for creating Laravel
- [ParadeDB](https://github.com/paradedb) for creating `pg_search`
- [ShabuShabu](https://github.com/ShabuShabu)
- [All Contributors](../../contributors)

Disclaimer
----------

[](#disclaimer)

This is a 3rd party package and ShabuShabu is not affiliated with either Laravel or ParadeDB.

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance79

Regular maintenance activity

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Every ~35 days

Recently: every ~99 days

Total

17

Last Release

190d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/31bd8ffbf4cfc6964e4bc0073b40d450e313c82d08c843b91899233be124ea71?d=identicon)[shabushabu](/maintainers/shabushabu)

---

Top Contributors

[![boris-glumpler](https://avatars.githubusercontent.com/u/580004?v=4)](https://github.com/boris-glumpler "boris-glumpler (193 commits)")

---

Tags

laravelshabushabuparadedbpg\_search

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.6k3](/packages/defstudio-telegraph)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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