SDK
SDK PHP v3.x
1

# collectionMapping

Creates a new CollectionMapping object, using its constructor.


# collectionMapping([mapping])

Arguments Type Description
mapping JSON Object Optional mapping

# Return Value

Returns the newly created CollectionMapping object.

# Usage

Copied to clipboard!
<?php
use \Kuzzle\Kuzzle;
use \Kuzzle\DataMapping;
$mapping = [
  'someField' => [
    'type' => 'string',
    'index' => 'analyzed'
  ]
];
$kuzzle = new Kuzzle('localhost');
$dataCollection = $kuzzle->collection('collection', 'index');
try {
  $dataMapping = $dataCollection->collectionMapping($mapping);
  // $dataMapping instanceof DataMapping
  $dataMapping->apply();
}
catch (ErrorException $e) {
}