Spatie\SearchIndex\SearchIndexHandlers\Elasticsearch::setIndexName PHP Method

setIndexName() public method

Set the name of the index that should be used by default.
public setIndexName ( $indexName )
$indexName
    public function setIndexName($indexName)
    {
        $this->indexName = $indexName;
        return $this;
    }

Usage Example

コード例 #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');
     });
 }
All Usage Examples Of Spatie\SearchIndex\SearchIndexHandlers\Elasticsearch::setIndexName