2017 © Pedro Peláez
 

symfony-bundle postgres-search-bundle

Tools to use full-text search PostgreSQL in Doctrine.

image

gkovrey/postgres-search-bundle

Tools to use full-text search PostgreSQL in Doctrine.

  • Tuesday, September 6, 2016
  • by gkovrey
  • Repository
  • 1 Watchers
  • 0 Stars
  • 878 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 25 Forks
  • 0 Open issues
  • 3 Versions
  • 14 % Grown

The README.md

PostgreSearchBundle

Symfony2 bundle with tools full-text search PostgreSQL in Doctrine 2., (*1)

Added type 'tsvector' to be used in the mapping., (*2)

Added functions 'to_tsquery', 'plainto_tsquery' and 'ts_rank' to be used in the DQL., (*3)

Step 1: Download PostgreSearchBundle using composer

Add PostgreSearchBundle in your composer.json:, (*4)

{
    "require": {
        "alsatian/postgres-search-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:, (*5)

``` bash $ php composer.phar update alsatian/postgres-search-bundle, (*6)


### Step 2: Enable the bundle Enable the bundle in the kernel: ``` php <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Alsatian\PostgresSearchBundle\AlsatianPostgresSearchBundle(), ); }

Step 3: Mapping example

/**
 * @var string
 *
 * @ORM\Column(name="search_fts", type="tsvector", options={"customSchemaOptions": {"searchFields":{"name", "genre"}}}, nullable=true)
 */
protected $searchFts;

Step 4: Use in DQL

$searchQuery = 'family | history';
$em = $this->getDoctrine()->getManager();
$query = $em->createQuery(
    'SELECT b.id, sum(TSRANK(b.searchFts, :searchQuery)) as rank
        FROM DemoSearchBundle:Books b
        WHERE TSQUERY( b.searchFts, :searchQuery, \'simple\' ) = true
        GROUP BY b.id
        ORDER BY rank DESC')
    ->setParameter('searchQuery', $searchQuery)
;
$result = $query->getArrayResult();

Result example:, (*7)

Array
(
    [0] => Array
        (
            [id] => 2
            [rank] => 0.0607927
        )
    [1] => Array
        (
            [id] => 3
            [rank] => 0.0303964
        )
)

The Versions

06/09 2016

dev-master

9999999-dev https://github.com/gkovrey/PostgresSearchBundle

Tools to use full-text search PostgreSQL in Doctrine.

  Sources   Download

MIT

The Requires

 

postgresql search symfony2 symfony3 doctrine2

06/09 2016

0.1.1

0.1.1.0 https://github.com/gkovrey/PostgresSearchBundle

Tools to use full-text search PostgreSQL in Doctrine.

  Sources   Download

MIT

The Requires

 

postgresql search symfony2 symfony3 doctrine2

30/06 2016

0.1

0.1.0.0 https://github.com/ddmaster/PostgresSearchBundle

Tools to use full-text search PostgreSQL in Doctrine.

  Sources   Download

MIT

The Requires

 

postgresql search symfony2 symfony3 doctrine2