当前位置: 首页>>代码示例>>PHP>>正文


PHP Mapping::create方法代码示例

本文整理汇总了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');
 }
开发者ID:r1pp3rj4ck,项目名称:FOSElasticaBundle,代码行数:11,代码来源:ResetterTest.php

示例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;
 }
开发者ID:r1pp3rj4ck,项目名称:FOSElasticaBundle,代码行数:20,代码来源:Resetter.php

示例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']));
 }
开发者ID:kskod,项目名称:Elastica,代码行数:26,代码来源:IndexTest.php

示例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();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:12,代码来源:Type.php

示例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();
 }
开发者ID:savdeep,项目名称:Elastica,代码行数:19,代码来源:Type.php


注:本文中的Elastica\Type\Mapping::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。