PHPackages                             vertigolabs/doctrine-full-text-postgres - 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. vertigolabs/doctrine-full-text-postgres

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

vertigolabs/doctrine-full-text-postgres
=======================================

Tools to use full-text searching in Postgresql with Doctrine

1.1.2(4y ago)1883.5k↓44.1%25[8 issues](https://github.com/jaimz22/DoctrineFullTextPostrgres/issues)[1 PRs](https://github.com/jaimz22/DoctrineFullTextPostrgres/pulls)2MITPHPPHP &gt;=5.4CI failing

Since Sep 20Pushed 2y ago4 watchersCompare

[ Source](https://github.com/jaimz22/DoctrineFullTextPostrgres)[ Packagist](https://packagist.org/packages/vertigolabs/doctrine-full-text-postgres)[ RSS](/packages/vertigolabs-doctrine-full-text-postgres/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (2)

DoctrineFullTextPostrgres
=========================

[](#doctrinefulltextpostrgres)

[![SensioLabsInsight](https://camo.githubusercontent.com/e3299770e3d12b52faba2823d81cd3ef2e045f547280ca92186df52b1ae19a0b/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f34373534633637302d333831612d343666652d613064362d3432623138396638336562642f6269672e706e67)](https://insight.sensiolabs.com/projects/4754c670-381a-46fe-a0d6-42b189f83ebd)

A simple to use set of database types, and annotations to use postgresql's full text search engine with doctrine

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

[](#installation)

- Register Doctrine Annotation:

```
\Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace("VertigoLabs\\DoctrineFullTextPostgres\\ORM\\Mapping\\");
```

- Register Doctrine Type:

```
Type::addType('tsvector',\VertigoLabs\DoctrineFullTextPostgres\ORM\Mapping\TsVectorType::class);
```

- Register Doctrine Event Subscriber

```
$this->em->getEventManager()->addEventSubscriber(new \VertigoLabs\DoctrineFullTextPostgres\Common\TsVectorSubscriber());
```

- Register Doctrine Functions

```
$doctrineConfig->addCustomStringFunction('tsquery', \VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsQueryFunction::class);
$doctrineConfig->addCustomStringFunction('tsplainquery', \VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsPlainQueryFunction::class);
$doctrineConfig->addCustomStringFunction('tsrank', \VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsRankFunction::class);
$doctrineConfig->addCustomStringFunction('tsrankcd', \VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsRankCDFunction::class);
```

Symfony installation
--------------------

[](#symfony-installation)

- Add to config

```
doctrine:
    dbal:
        types:
            tsvector:   VertigoLabs\DoctrineFullTextPostgres\DBAL\Types\TsVector
        mapping_types:
            tsvector: tsvector
    orm:
        entity_managers:
            default:
                dql:
                    string_functions:
                        tsquery: VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsQueryFunction
                        tsplainquery: VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsPlainQueryFunction
                        tsrank: VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsRankFunction
                        tsrankcd: VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsRankCDFunction

services:
        vertigolabs.doctrinefulltextpostgres.listener:
                 class: VertigoLabs\DoctrineFullTextPostgres\Common\TsVectorSubscriber
                 tags:
                     - { name: doctrine.event_subscriber, connection: default }
```

Usage
-----

[](#usage)

- Create your entity

You do not have to create column annotations for your fields that will hold your full text search vectors (tsvector) the columns will be created automatically. A TsVector annotation only requires the `fields` parameter. There are optional `weight` and `language` parameters as well, however they are not used yet. You do not need to set data for your TsVector field, the data will come from the fields specified in the `fields` property automatically when the object is flushed to the database

```
use VertigoLabs\DoctrineFullTextPostgres\ORM\Mapping\TsVector;

class Article
{
    /**
     * @var string
     * @Column(name="title", type="string", nullable=false)
     */
    private $title;

    /**
     * @var TsVector
     * @TsVector(name="title_fts", fields={"title"})
     */
    private $titleFTS;

    /**
     * @var string
     * @Column(name="body", type="text", nullable=true)
     */
    private $body;

     /**
     * @var TsVector
     * @TsVector(name="body_fts", fields={"body"})
     */
    private $bodyFTS;
}
```

- Insert some data

You do not need to worry about setting any data to the fields marked with the TsVector annotation. The data for these fields will be automatically populated when you flush your changes to the database.

```
$article = new Article();
$article->setTitle('Baboons Invade Seaworld');
$article->setBody('In a crazy turn of events a pack a rabid red baboons invade Seaworld. Officials say that the Dolphins are being held hostage');
$this->em->persist($article);
$this->em->flush();
```

- Query your database!

When you query your database, you'll query against the actual data. the query will be modified to search using the fields marked with the TsVector annotation automatically

```
$query = $this->em->createQuery('SELECT a FROM Article a WHERE tsquery(a.title,:searchQuery) = true');
$query->setParameter('searchQuery','Baboons');
$result = $query->getArrayResult();
```

If you'd like to retrieve the ranking of your full text search, simply use the tsrank function:

```
$query = $this->em->createQuery('SELECT a, tsrank(a.title,:searchQuery) as rank FROM Article a WHERE tsquery(a.title,:searchQuery) = true');
$query->setParameter('searchQuery','Baboons');
$result = $query->getArrayResult();

var_dump($result[0]['rank']); // int 0.67907
```

You can even order by rank:

```
$query = $this->em->createQuery('SELECT a FROM Article a WHERE tsquery(a.title,:searchQuery) = true ORDER BY tsrank(a.title,:searchQuery) DESC');
```

TODO
----

[](#todo)

- Add language to SQL field definition
- Add language and weighting to queries

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance11

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 68% 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 ~735 days

Total

4

Last Release

1687d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/53254d08df6c002757411c25e1c1c3fd6af315db3f05c22859050b16aed1ba1c?d=identicon)[jaimz22](/maintainers/jaimz22)

---

Top Contributors

[![jaimz22](https://avatars.githubusercontent.com/u/5921193?v=4)](https://github.com/jaimz22 "jaimz22 (17 commits)")[![teohhanhui](https://avatars.githubusercontent.com/u/548843?v=4)](https://github.com/teohhanhui "teohhanhui (2 commits)")[![kobusbeljaars](https://avatars.githubusercontent.com/u/6917246?v=4)](https://github.com/kobusbeljaars "kobusbeljaars (1 commits)")[![luca-nardelli](https://avatars.githubusercontent.com/u/6215162?v=4)](https://github.com/luca-nardelli "luca-nardelli (1 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (1 commits)")[![dizzy7](https://avatars.githubusercontent.com/u/1052472?v=4)](https://github.com/dizzy7 "dizzy7 (1 commits)")[![Vincz](https://avatars.githubusercontent.com/u/400525?v=4)](https://github.com/Vincz "Vincz (1 commits)")[![freezlite](https://avatars.githubusercontent.com/u/3983804?v=4)](https://github.com/freezlite "freezlite (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vertigolabs-doctrine-full-text-postgres/health.svg)

```
[![Health](https://phpackages.com/badges/vertigolabs-doctrine-full-text-postgres/health.svg)](https://phpackages.com/packages/vertigolabs-doctrine-full-text-postgres)
```

###  Alternatives

[kitpages/data-grid-bundle

Symfony DataGridBundle

7780.9k1](/packages/kitpages-data-grid-bundle)[ddmaster/postgre-search-bundle

Tools to use full-text search PostgreSQL in Doctrine.

1289.9k](/packages/ddmaster-postgre-search-bundle)

PHPackages © 2026

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