From 123d9138ba763588e1502e15cf9ccbe3859ee8fc Mon Sep 17 00:00:00 2001 From: jlinn Date: Wed, 29 May 2013 12:56:14 -0700 Subject: [PATCH] #330 Add _meta to mapping. --- lib/Elastica/Type/Mapping.php | 11 +++++++++++ test/lib/Elastica/Test/Type/MappingTest.php | 15 +++++++++++++++ 2 files changed, 26 insertions(+) mode change 100644 => 100755 lib/Elastica/Type/Mapping.php mode change 100644 => 100755 test/lib/Elastica/Test/Type/MappingTest.php 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']); + } }