Put Mappings APIedit

The Put Mappings API allows you to modify or add to an existing index’s mapping.

// Set the index and type
$params['index'] = 'my_index';
$params['type']  = 'my_type2';

// Adding a new type to an existing index
$myTypeMapping2 = array(
    '_source' => array(
        'enabled' => true
    ),
    'properties' => array(
        'first_name' => array(
            'type' => 'string',
            'analyzer' => 'standard'
        ),
        'age' => array(
            'type' => 'integer'
        )
    )
);
$params['body']['my_type2'] = $myTypeMapping2;

// Update the index mapping
$client->indices()->putMapping($params);