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


PHP Mapping::setParent方法代码示例

本文整理汇总了PHP中Elastica\Type\Mapping::setParent方法的典型用法代码示例。如果您正苦于以下问题:PHP Mapping::setParent方法的具体用法?PHP Mapping::setParent怎么用?PHP Mapping::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Elastica\Type\Mapping的用法示例。


在下文中一共展示了Mapping::setParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testHasParent

 /**
  * @group functional
  */
 public function testHasParent()
 {
     $index = $this->_createIndex();
     $shopType = $index->getType('shop');
     $productType = $index->getType('product');
     $mapping = new Mapping();
     $mapping->setParent('shop');
     $productType->setMapping($mapping);
     $shopType->addDocuments(array(new Document('zurich', array('brand' => 'google')), new Document('london', array('brand' => 'apple'))));
     $doc1 = new Document(1, array('device' => 'chromebook'));
     $doc1->setParent('zurich');
     $doc2 = new Document(2, array('device' => 'macmini'));
     $doc2->setParent('london');
     $productType->addDocument($doc1);
     $productType->addDocument($doc2);
     $index->refresh();
     // All documents
     $parentQuery = new HasParent(new MatchAll(), $shopType->getName());
     $search = new Search($index->getClient());
     $results = $search->search($parentQuery);
     $this->assertEquals(2, $results->count());
     $match = new Match();
     $match->setField('brand', 'google');
     $parentQuery = new HasParent($match, $shopType->getName());
     $search = new Search($index->getClient());
     $results = $search->search($parentQuery);
     $this->assertEquals(1, $results->count());
     $result = $results->current();
     $data = $result->getData();
     $this->assertEquals($data['device'], 'chromebook');
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:34,代码来源:HasParentTest.php

示例2: _getTestIndex

 protected function _getTestIndex()
 {
     $index = $this->_createIndex('has_child_test');
     $parentType = $index->getType('parent');
     $childType = $index->getType('child');
     $childMapping = new Mapping($childType);
     $childMapping->setParent('parent');
     $childMapping->send();
     $altType = $index->getType('alt');
     $altDoc = new Document('alt1', array('name' => 'altname'));
     $altType->addDocument($altDoc);
     $parent1 = new Document('parent1', array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com'));
     $parentType->addDocument($parent1);
     $parent2 = new Document('parent2', array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com'));
     $parentType->addDocument($parent2);
     $child1 = new Document('child1', array('id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com'));
     $child1->setParent('parent1');
     $childType->addDocument($child1);
     $child2 = new Document('child2', array('id' => 'child2', 'user' => 'child2', 'email' => 'child2@test.com'));
     $child2->setParent('parent2');
     $childType->addDocument($child2);
     $child3 = new Document('child3', array('id' => 'child3', 'user' => 'child3', 'email' => 'child3@test.com', 'alt' => array(array('name' => 'testname'))));
     $child3->setParent('parent2');
     $childType->addDocument($child3);
     $index->refresh();
     return $index;
 }
开发者ID:makeandship,项目名称:wordpress-fantastic-elasticsearch,代码行数:27,代码来源:HasChildTest.php

示例3: testParentMapping

 /**
  * @group functional
  */
 public function testParentMapping()
 {
     $index = $this->_createIndex();
     $childtype = new Type($index, 'childtype');
     $childmapping = new Mapping($childtype, array('name' => array('type' => 'string', 'store' => true)));
     $childmapping->setParent('parenttype');
     $childtype->setMapping($childmapping);
     $data = $childmapping->toArray();
     $this->assertEquals('parenttype', $data[$childtype->getName()]['_parent']['type']);
     $parenttype = new Type($index, 'parenttype');
     $parentmapping = new Mapping($parenttype, array('name' => array('type' => 'string', 'store' => true)));
     $parenttype->setMapping($parentmapping);
 }
开发者ID:zhangxiaoliu,项目名称:Elastica,代码行数:16,代码来源:MappingTest.php

示例4: createType

 /**
  * {@inheritDoc}
  */
 public function createType(ClassMetadata $metadata)
 {
     $type = $this->getIndex($metadata->index)->getType($metadata->type);
     $properties = $this->getMapping($metadata->fieldMappings);
     $rootProperties = $this->getRootMapping($metadata->rootMappings);
     $mapping = new Mapping($type, $properties);
     $mapping->disableSource($metadata->source);
     if (isset($metadata->boost)) {
         $mapping->setParam('_boost', array('name' => '_boost', 'null_value' => $metadata->boost));
     }
     if (isset($metadata->parent)) {
         $mapping->setParent($metadata->parent);
     }
     foreach ($rootProperties as $key => $value) {
         $mapping->setParam($key, $value);
     }
     $mapping->send();
     return $type;
 }
开发者ID:akleiber,项目名称:search,代码行数:22,代码来源:Client.php


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