diff --git a/lib/Elastica/Type/Mapping.php b/lib/Elastica/Type/Mapping.php old mode 100644 new mode 100755 index 42cb98e8dc..b281a5dd99 --- a/lib/Elastica/Type/Mapping.php +++ b/lib/Elastica/Type/Mapping.php @@ -71,6 +71,17 @@ public function setProperties(array $properties) return $this->setParam('properties', $properties); } + /** + * Sets the mapping _meta + * @param array $meta metadata + * @return \Elastica\Type\Mapping Mapping object + * @link http://www.elasticsearch.org/guide/reference/mapping/meta.html + */ + public function setMeta(array $meta) + { + return $this->setParam('_meta', $meta); + } + /** * Returns mapping type * diff --git a/test/lib/Elastica/Test/Type/MappingTest.php b/test/lib/Elastica/Test/Type/MappingTest.php old mode 100644 new mode 100755 index e885b816b9..c7ec859c19 --- a/test/lib/Elastica/Test/Type/MappingTest.php +++ b/test/lib/Elastica/Test/Type/MappingTest.php @@ -245,4 +245,19 @@ public function testDynamicTemplate() 'Indexing status of the multiname.org not available. Dynamic mapping not fully applied!'); $this->assertEquals('not_analyzed', $newMapping['person']['properties']['multiname']['fields']['org']['index']); } + + public function testSetMeta() + { + $index = $this->_createIndex(); + $type = $index->getType('test'); + $mapping = new Mapping($type, array( + 'firstname' => array('type' => 'string', 'store' => 'yes'), + 'lastname' => array('type' => 'string') + )); + $mapping->setMeta(array('class' => 'test')); + $type->setMapping($mapping); + + $mappingData = $type->getMapping(); + $this->assertEquals('test', $mappingData['test']['_meta']['class']); + } }