Set the name of the index that should be used by default.
public setIndexName ( $indexName ) | ||
$indexName |
/** * 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'); }); }
/** * 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'); }); }