getIndex() public method

Returns the index for the given connection
public getIndex ( string $name = null ) : Index
$name string Index name to create connection to, if no value is passed it will use the default index name for the connection.
return Elastica\Index Index for the given name
コード例 #1
0
 /**
  * Returns an empty array as a shim for fixtures
  *
  * @return array An empty array
  */
 public function listTables()
 {
     try {
         $index = $this->connection->getIndex();
         $mappings = $index->getMapping();
     } catch (ResponseException $e) {
         return [];
     }
     return array_keys($mappings);
 }
コード例 #2
0
 /**
  * Truncate the fixture type.
  *
  * @param \Cake\ElasticSearch\Datasource\Connection $db The Elasticsearch
  *  connection
  * @return void
  */
 public function truncate(Connection $db)
 {
     $query = new MatchAll();
     $index = $db->getIndex();
     $type = $index->getType($this->table);
     $type->deleteByQuery($query);
     $index->refresh();
 }