本文整理汇总了PHP中Elastica\Type\Mapping::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Mapping::create方法的具体用法?PHP Mapping::create怎么用?PHP Mapping::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Type\Mapping
的用法示例。
在下文中一共展示了Mapping::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIndexMappingForParent
public function testIndexMappingForParent()
{
$type = $this->getMockElasticaType();
$this->indexConfigsByName['parent']['index']->expects($this->once())->method('getType')->with('a')->will($this->returnValue($type));
$type->expects($this->once())->method('delete');
$mapping = Mapping::create($this->indexConfigsByName['parent']['config']['mappings']['a']['properties']);
$mapping->setParam('_parent', array('type' => 'b'));
$type->expects($this->once())->method('setMapping')->with($mapping);
$resetter = new Resetter($this->indexConfigsByName);
$resetter->resetIndexType('parent', 'a');
}
示例2: createMapping
/**
* create type mapping object
*
* @param array $indexConfig
* @return Mapping
*/
protected function createMapping($indexConfig)
{
$mapping = Mapping::create($indexConfig['properties']);
$mappingSpecialFields = array('_uid', '_id', '_source', '_all', '_analyzer', '_boost', '_routing', '_index', '_size', '_timestamp', '_ttl', 'dynamic_templates');
foreach ($mappingSpecialFields as $specialField) {
if (isset($indexConfig[$specialField])) {
$mapping->setParam($specialField, $indexConfig[$specialField]);
}
}
if (isset($indexConfig['_parent'])) {
$mapping->setParam('_parent', array('type' => $indexConfig['_parent']['type']));
}
return $mapping;
}
示例3: testExcludeFileSource
public function testExcludeFileSource()
{
$indexMapping = array('file' => array('type' => 'attachment', 'store' => 'yes'), 'text' => array('type' => 'string', 'store' => 'yes'), 'title' => array('type' => 'string', 'store' => 'yes'));
$indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0));
$index = $this->_createIndex();
$type = new Type($index, 'content');
$mapping = Mapping::create($indexMapping);
$mapping->setSource(array('excludes' => array('file')));
$mapping->setType($type);
$index->create($indexParams, true);
$type->setMapping($mapping);
$docId = 1;
$text = 'Basel World';
$title = 'No Title';
$doc1 = new Document($docId);
$doc1->addFile('file', BASE_PATH . '/data/test.docx');
$doc1->set('text', $text);
$doc1->set('title', $title);
$type->addDocument($doc1);
// Optimization necessary, as otherwise source still in realtime get
$index->optimize();
$data = $type->getDocument($docId)->getData();
$this->assertEquals($data['title'], $title);
$this->assertEquals($data['text'], $text);
$this->assertFalse(isset($data['file']));
}
示例4: setMapping
/**
* Sets value type mapping for this type
*
* @param \Elastica\Type\Mapping|array $mapping Elastica\Type\MappingType object or property array with all mappings
* @return \Elastica\Response
*/
public function setMapping($mapping)
{
$mapping = Mapping::create($mapping);
$mapping->setType($this);
return $mapping->send();
}
示例5: setMapping
/**
* Sets value type mapping for this type.
*
* @param \Elastica\Type\Mapping|array $mapping Elastica\Type\MappingType object or property array with all mappings
* @param argArray = array('_timestamp' => array('enabled' => true, 'store' => 'yes'), '_ttl' => array('enabled' => true));
*
* @return \Elastica\Response
*/
public function setMapping($mapping, $argArray = NULL)
{
$mapping = Mapping::create($mapping);
$mapping->setType($this);
if (isset($argArray) && is_array($argArray)) {
foreach ($argArray as $key => $valueArr) {
$mapping->setParam($key, $valueArr);
}
}
return $mapping->send();
}