SDK
SDK PHP v3.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

CollectionMapping #

When creating a new collection in the persistent data storage layer, Kuzzle uses a default mapping. This means that, by default, you won't be able to exploit the full capabilities of our persistent data storage layer (currently handled by ElasticSearch), and your searches may suffer from below-average performance, depending on the amount of data you stored in a collection and the complexity of your database.

The CollectionMapping object allows you to get the current mapping in a collection and to modify it if necessary.

Once a field mapping has been set, it cannot be removed without recreating the collection.


CollectionMapping(Collection, [mapping]) #

Arguments Type Description
Collection Collection An instantiated Collection object
mapping JSON Object Optional mapping

Properties #

Property name Type Description get/set
headers JSON Object Common headers for all sent documents. get/set
mapping object Easy-to-understand list of mappings per field get/set

Note: the headers property is inherited from the provided Collection object and can be overrided

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');
$dataMapping = $dataCollection->collectionMapping($mapping);
// $dataMapping instanceof DataMapping