Elastica\Index::getMapping PHP Method

getMapping() public method

Gets all the type mappings for an index.
public getMapping ( ) : array
return array
    public function getMapping()
    {
        $path = '_mapping';
        $response = $this->request($path, Request::GET);
        $data = $response->getData();
        // Get first entry as if index is an Alias, the name of the mapping is the real name and not alias name
        $mapping = array_shift($data);
        if (isset($mapping['mappings'])) {
            return $mapping['mappings'];
        }
        return [];
    }

Usage Example

Example #1
0
 /**
  * @return array
  */
 public function getMetaData()
 {
     $metaData = [];
     try {
         $mapping = $this->index->getMapping();
         if (isset($mapping['page']) && isset($mapping['page']['_meta'])) {
             $metaData = $mapping['page']['_meta'];
         }
     } catch (ResponseException $e) {
         // legal catch, if no mapping found (fresh installation etc) we still want to show empty meta data
     }
     return $metaData;
 }
All Usage Examples Of Elastica\Index::getMapping