AlgoliaSearch\Client::initIndex PHP Method

initIndex() public method

Get the index object initialized (no server call needed for initialization).
public initIndex ( string $indexName ) : Index
$indexName string the name of index
return Index
    public function initIndex($indexName)
    {
        if (empty($indexName)) {
            throw new AlgoliaException('Invalid index name: empty string');
        }
        return new Index($this->context, $this, $indexName);
    }

Usage Example

 /**
  * AlgoliaSearchEngine constructor.
  * @param \AlgoliaSearch\Client $client
  * @param $index
  */
 public function __construct(\AlgoliaSearch\Client $client, $index, $clearOnSync)
 {
     $this->client = $client;
     $this->index = $client->initIndex($index);
     $this->clearOnSync = $clearOnSync;
     $this->index->setSettings(array("attributesToIndex" => array("content", "title", "categories", "tags"), "attributesForFaceting" => array("categories", "tags")));
 }
All Usage Examples Of AlgoliaSearch\Client::initIndex