/**
* 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');
});
}