1. Go to this page and download the library: Download floriansemm/solr-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/ */
/**
* @Solr\Document(repository="My/Custom/Repository")
*/
class SomeEntity
{
// ...
}
/**
* @Solr\Document(index="core0")
*/
class SomeEntity
{
// ...
}
/**
* @Solr\Document(indexHandler="indexHandler")
*/
class SomeEntity
{
public function indexHandler()
{
if ($this->language == 'en') {
return 'core0';
}
}
}
class Post
{
/**
* @Solr\Id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
}
/**
* // ....
* @Solr\SynchronizationFilter(callback="shouldBeIndexed")
*/
class SomeEntity
{
/**
* @return boolean
*/
public function shouldBeIndexed()
{
// put your logic here
}
}
public function find($id)
{
$this->hydrationMode = HydrationModes::HYDRATE_INDEX;
return parent::find($id);
}
namespace AppBundle\Search;
use FS\SolrBundle\Repository\Repository;
class ProviderRepository extends Repository
{
public function findPost($what)
{
$query = $this->solr->createQuery('AcmeDemoBundle:Post');
// some query-magic here
return $query->getResult();
}
}