當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。