Inheritance: implements Spatie\SearchIndex\SearchIndexHandler
コード例 #1
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('searchIndex', function ($app) {
         switch ($app['config']->get('searchindex.engine')) {
             case 'elasticsearch':
                 $config = $app['config']->get('searchindex.elasticsearch');
                 $elasticSearchClient = new ElasticsearchClient(['hosts' => $config['hosts'], 'logPath' => $config['logPath'], 'logLevel' => $config['logLevel']]);
                 $searchHandler = new SearchHandler($elasticSearchClient);
                 $searchHandler->setIndexName($config['defaultIndexName']);
                 return $searchHandler;
         }
         throw new Exception($app['config']->get('searchindexvend.engine') . ' is not a valid search engine');
     });
 }
コード例 #2
0
 /**
  * Register the service provider.
  */
 public function register()
 {
     $this->app->singleton('searchIndex', function ($app) {
         switch ($app['config']->get('searchindex.engine')) {
             case 'elasticsearch':
                 $config = $app['config']->get('searchindex.elasticsearch');
                 $elasticSearchClient = new ElasticsearchClient(['hosts' => $config['hosts'], 'logPath' => $config['logPath'], 'logLevel' => $config['logLevel']]);
                 $searchHandler = new ElasticSearchHandler($elasticSearchClient);
                 $searchHandler->setIndexName($config['defaultIndexName']);
                 return $searchHandler;
                 break;
             case 'algolia':
                 $config = $app['config']->get('searchindex.algolia');
                 $algoliaClient = new \AlgoliaSearch\Client($config['application-id'], $config['api-key']);
                 $searchHandler = new Algolia($algoliaClient);
                 $searchHandler->setIndexName($config['defaultIndexName']);
                 return $searchHandler;
                 break;
         }
         throw new Exception($app['config']->get('searchindex.engine') . ' is not a valid search engine');
     });
 }
コード例 #3
0
 /**
  * Get the results for the given query
  *
  * @param array $query
  * @return mixed
  */
 public function getResults($query)
 {
     return $this->elasticsearch->search($query);
 }