dataMapping.set('field', {type: 'string', index: 'analyzed', null_value: ''});
JSONObject mapping = new JSONObject();
mapping.put("type", "string");
mapping.put("index", "analyzed");
mapping.put("null_value", "");

dataMapping.set("field", mapping);

use \Kuzzle\DataMapping;

// ...

$field = 'field';
$mapping = [
  'type' => 'string',
  'index' => 'analyzed',
  'null_value' => ''

 * @var $dataMapping DataMapping
$dataMapping->set($field, $mapping);

Adds or updates a field mapping.

set(field, mapping)

fieldstringName of the field from which the mapping is to be added or updated
mappingJSON ObjectMapping for this field, following the Elasticsearch Mapping format

Return value

Returns this CollectionMapping object to allow chaining.