Example #1
0
 /**
  * Performs a Full text search on this collection, and returns a Collection of Models
  * 
  * @param  string $q       Search query
  * @param  array  $filter  Restrict the results
  * 
  * @return Collection
  */
 public static function textSearch($q, $filter = array())
 {
     $collectionName = static::getCollectionName();
     $search = Mongovel::db()->command(array('text' => $collectionName, 'search' => $q, 'filter' => $filter));
     $items = array();
     if (isset($search['results'])) {
         foreach ($search['results'] as $r) {
             $items[] = static::create($r['obj']);
         }
     }
     return new Collection($items);
 }