PHP code example of ddmaster / postgre-search-bundle

1. Go to this page and download the library: Download ddmaster/postgre-search-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ddmaster / postgre-search-bundle example snippets


/**
 * @var string
 *
 * @ORM\Column(name="search_fts", type="tsvector", nullable=true)
 */
private $searchFts;

$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 ) = true
        GROUP BY b.id
        ORDER BY rank DESC')
    ->setParameter('searchQuery', $searchQuery)
;
$result = $query->getArrayResult();
 bash
$ php composer.phar update ddmaster/postgre-search-bundle
 php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Ddmaster\PostgreSearchBundle\PostgreSearchBundle(),
    );
}