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/ */
$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();