Example #1
0
 /**
  * Execute the current query and return the results.
  *
  * @return array
  */
 public function get()
 {
     $options = array();
     if ($this->columns) {
         $options['columns'] = $this->columns;
     }
     if ($this->limit) {
         $options['limit'] = $this->limit;
         $options['offset'] = $this->offset;
     }
     $this->executeCallbacks();
     $results = $this->index->runQuery($this->query, $options);
     if ($this->columns && !in_array('*', $this->columns)) {
         $new_results = array();
         foreach ($results as $result) {
             $new_result = array();
             foreach ($this->columns as $field) {
                 if (array_key_exists($field, $result)) {
                     $new_result[$field] = $result[$field];
                 }
             }
             $new_results[] = $new_result;
         }
         $results = $new_results;
     }
     return $results;
 }
Example #2
0
 /**
  * Return the instance associated with the requested index name.
  * Will create one if needed.
  *
  * @param string $index
  * 
  * @return \Mmanos\Search\Index
  */
 public function index($index = null)
 {
     if (null === $index) {
         $index = Config::get('laravel-search::default_index', 'default');
     }
     if (!isset($this->indexes[$index])) {
         $this->indexes[$index] = Index::factory($index, $this->driver);
     }
     return $this->indexes[$index];
 }
Example #3
0
 /**
  * Create a new zend instance.
  *
  * @param string $name
  * @param string $driver
  * 
  * @return void
  */
 public function __construct($name, $driver)
 {
     parent::__construct($name, $driver);
     \ZendSearch\Lucene\Search\QueryParser::setDefaultEncoding('UTF-8');
 }