Exemplo n.º 1
0
 /**
  * Finds all active records that matches the given criteria using solr
  * @param ASolrCriteria $criteria the solr criteria to use for searching
  * @return CActiveRecord[] an array of results
  */
 public function findAllBySolr($criteria = null)
 {
     $c = new ASolrCriteria();
     $c->mergeWith($this->getSolrCriteria());
     if ($criteria !== null) {
         $c->mergeWith($criteria);
     }
     if ($c->getQuery() == "") {
         $c->setQuery("*:*");
     }
     return $this->populateFromSolr($this->getSolrDocument()->findAll($c), true);
 }
Exemplo n.º 2
0
 /**
  * Finds multiple solr document that have the specified attribute values.
  * @param array $attributes list of attribute values (indexed by attribute names) that the solr documents should match.
  * @param ASolrCriteria $criteria The solr search criteria
  * @return ASolrDocument[] the documents found.
  */
 public function findAllByAttributes($attributes, $criteria = null)
 {
     Yii::trace(get_class($this) . '.findAllByAttributes()', 'packages.solr.ASolrDocument');
     if ($criteria === null) {
         $criteria = new ASolrCriteria();
     }
     $query = array();
     foreach ($attributes as $attribute => $value) {
         $query[] = $attribute . ":" . $value;
     }
     $criteria->setQuery(implode(" AND ", $query));
     return $this->query($criteria, true);
 }
Exemplo n.º 3
0
 /**
  * An example of a solr named scope
  * @return ExampleExtendedSolrDocument $this with the scope applied
  */
 public function exampleScope()
 {
     $criteria = new ASolrCriteria();
     $criteria->setLimit(100);
     $criteria->setQuery('name:test');
     $this->getSolrCriteria()->mergeWith($criteria);
     return $this;
 }