/** * {@inheritdoc} */ public function findBy(array $args) { $query = $this->solr->createQuery($this->entity); foreach ($args as $fieldName => $fieldValue) { $query->addSearchTerm($fieldName, $fieldValue); } return $this->solr->query($query); }
public function testCreateQuery_ValidEntity() { $this->setupMetaFactoryLoadOneCompleteInformation(); $solr = new Solr($this->solrClientFake, $this->commandFactory, $this->eventDispatcher, $this->metaFactory, $this->mapper); $query = $solr->createQuery('FSBlogBundle:ValidTestEntity'); $this->assertTrue($query instanceof SolrQuery); $this->assertEquals(4, count($query->getMappedFields())); }
/** * {@inheritdoc} */ public function findOneBy(array $args) { $metaInformation = $this->solr->getMetaFactory()->loadInformation($this->entity); $query = $this->solr->createQuery($this->entity); $query->setHydrationMode($this->hydrationMode); $query->setRows(1); $query->setUseAndOperator(true); $query->addSearchTerm('id', $metaInformation->getDocumentName() . '_*'); $query->setQueryDefaultField('id'); $helper = $query->getHelper(); foreach ($args as $fieldName => $fieldValue) { $fieldValue = $helper->escapeTerm($fieldValue); $query->addSearchTerm($fieldName, $fieldValue); } $found = $this->solr->query($query); return array_pop($found); }