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


PHP Type::exists方法代码示例

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


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

示例1: updateMappings

 /**
  * Create new mappings or update existing mappings
  */
 public function updateMappings()
 {
     /** @var ClassMetadata[] $metadatas */
     $metadatas = $this->sm->getMetadataFactory()->getAllMetadata();
     // Refresh all the mappings
     foreach ($metadatas as $metadata) {
         // if we're in the dev env, set the number of replicas to be 0
         if ($this->env == 'dev' || $this->env == 'test_local') {
             $metadata->numberOfReplicas = 0;
         }
         // create the index if it doesn't exist yet
         $indexName = $metadata->timeSeriesScale ? $metadata->getCurrentTimeSeriesIndex() : $metadata->index;
         /** @var Index $index */
         $index = $this->client->getIndex($indexName);
         if (!$index->exists()) {
             $this->client->createIndex($indexName, $metadata->getSettings());
         }
         // create the type if it doesn't exist yet
         if ($metadata->type) {
             $type = new Type($index, $metadata->type);
             if (!$type->exists()) {
                 $this->client->createType($metadata);
             }
             // update the mapping
             $result = $this->client->updateMapping($metadata);
             if (true !== $result) {
                 echo "Warning: Failed to update mapping for index '{$indexName}', type '{$metadata->type}'. Reason: {$result}\n";
             }
         }
     }
 }
开发者ID:revinate,项目名称:search-bundle,代码行数:34,代码来源:MappingManager.php

示例2: getType

 /**
  * Get the currentType
  *
  * @param      $type
  * @param bool $createNew
  *
  * @return \Elastica\Type
  */
 public function getType($type, $createNew = false)
 {
     $this->_type = $this->_index->getType($type);
     if ($createNew == true && $this->_type->exists() == true) {
         $this->_type->delete();
     }
     return $this->_type;
 }
开发者ID:vadimjustus,项目名称:m2-elasticsearch,代码行数:16,代码来源:Elastic.php

示例3: deleteMapping

 /**
  * @param string $typeName
  * @return \Elastica\Type
  * @throws \Exception
  */
 protected function deleteMapping($typeName)
 {
     $type = new Elastica\Type($this->index, $typeName);
     if ($type->exists()) {
         try {
             $type->delete();
         } catch (\Exception $e) {
             throw new \Exception('Could not delete type ' . $type->getName() . '');
         }
     }
     $type = new Elastica\Type($this->index, $typeName);
     return $type;
 }
开发者ID:randomresult,项目名称:WMDB.Forger,代码行数:18,代码来源:SetupCommandController.php

示例4: testExists

 /**
  * @group functional
  */
 public function testExists()
 {
     $index = $this->_createIndex();
     $this->assertTrue($index->exists());
     $type = new Type($index, 'user');
     $this->assertFalse($type->exists());
     $type->addDocument(new Document(1, array('name' => 'test name')));
     $index->optimize();
     // sleep a moment to be sure that all nodes in cluster has new type
     sleep(5);
     //Test if type exists
     $this->assertTrue($type->exists());
     $index->delete();
     $this->assertFalse($index->exists());
 }
开发者ID:bungkoko,项目名称:Elastica,代码行数:18,代码来源:TypeTest.php

示例5: testExists

 public function testExists()
 {
     $index = $this->_createIndex();
     $this->assertTrue($index->exists());
     $type = new Type($index, 'user');
     $this->assertFalse($type->exists());
     $type->addDocument(new Document(1, array('name' => 'test name')));
     $index->optimize();
     //Test if type exists
     $this->assertTrue($type->exists());
     $index->delete();
     $this->assertFalse($index->exists());
 }
开发者ID:tkaven,项目名称:Elastica,代码行数:13,代码来源:TypeTest.php


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