Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _meta to mapping #393

Merged
merged 2 commits into from
May 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
CHANGES

2013-05-29
- Add _meta to mapping. #330

2013-05-23
- add support PSR-3(https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
- Elastica\Log implement LoggerInterface(extends Psr\Log\AbstractLogger)
Expand Down
11 changes: 11 additions & 0 deletions lib/Elastica/Type/Mapping.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
15 changes: 15 additions & 0 deletions test/lib/Elastica/Test/Type/MappingTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}