Elastica\Index::exists PHP Method

exists() public method

Checks if the given index is already created.
public exists ( ) : boolean
return boolean True if index exists
    public function exists()
    {
        $response = $this->getClient()->request($this->getName(), Request::HEAD);
        $info = $response->getTransferInfo();
        return (bool) ($info['http_code'] == 200);
    }

Usage Example

 /**
  * @return Index
  */
 private function getIndex()
 {
     if (null === $this->index) {
         $this->index = $this->client->getIndex($this->indexName);
         if (!$this->index->exists()) {
             $this->index->create();
         }
     }
     return $this->index;
 }
All Usage Examples Of Elastica\Index::exists