當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Document::setType方法代碼示例

本文整理匯總了PHP中Elastica\Document::setType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Document::setType方法的具體用法?PHP Document::setType怎麽用?PHP Document::setType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Elastica\Document的用法示例。


在下文中一共展示了Document::setType方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getDocument

 /**
  * Convert a log message into an Elastica Document
  *
  * @param  array $record Log message
  * @return Document
  */
 protected function getDocument($record)
 {
     $document = new Document();
     $document->setData($record);
     $document->setType($this->type);
     $document->setIndex($this->index);
     return $document;
 }
開發者ID:saj696,項目名稱:pipe,代碼行數:14,代碼來源:ElasticaFormatter.php

示例2: getDocument

 public function getDocument($record)
 {
     $user = $this->token->getToken()->getUser();
     $record['extra']['user'] = $user->getId();
     $document = new Document();
     $document->setData($record);
     $document->setType($this->type);
     $document->setIndex($this->index);
     return $document;
 }
開發者ID:ABeloeil,項目名稱:lift,代碼行數:10,代碼來源:ElasticaFormatter.php

示例3: testSetIndex

 /**
  * @group unit
  */
 public function testSetIndex()
 {
     $document = new Document();
     $document->setIndex('index2');
     $document->setType('type2');
     $this->assertEquals('index2', $document->getIndex());
     $this->assertEquals('type2', $document->getType());
     $index = new Index($this->_getClient(), 'index');
     $document->setIndex($index);
     $this->assertEquals('index', $document->getIndex());
     $this->assertEquals('type2', $document->getType());
 }
開發者ID:MediaWiki-stable,項目名稱:1.26.1,代碼行數:15,代碼來源:DocumentTest.php

示例4: register

 /**
  * {@inheritdoc}
  * @see \Silex\ServiceProviderInterface::register()
  */
 public function register(Application $app)
 {
     $app['elastic.client'] = $app->share(function () use($app) {
         $config = $app['config']('elastic.connection', array());
         $client = new Client($config);
         return $client;
     });
     $app['elastic.bulk'] = $app->protect(function ($index) use($app) {
         $bulk = new Bulk($app['elastic.client']);
         $bulk->setIndex($index);
         return $bulk;
     });
     $app['elastic.document'] = $app->protect(function ($type, array $data) {
         $document = new Document();
         $document->setType($type);
         $document->setData($data);
         return $document;
     });
 }
開發者ID:skymeyer,項目名稱:csp-report-collector,代碼行數:23,代碼來源:ElasticService.php

示例5: createDocument

 /**
  * @param string $id
  * @param array|string $data
  * @return Document
  */
 public function createDocument($id = '', $data = array())
 {
     $document = new Document($id, $data);
     $document->setType($this);
     return $document;
 }
開發者ID:janaece,項目名稱:globalclassroom4_clean,代碼行數:11,代碼來源:Type.php

示例6: testBulkType

 /**
  * Test bulk operations on Type.
  *
  * @group functional
  */
 public function testBulkType()
 {
     $type = $this->_getClient()->getIndex('cryptocurrencies')->getType('altcoin');
     $liteCoin = new Document(1, array('name' => 'litecoin'));
     $nameCoin = new Document(2, array('name' => 'namecoin'));
     $type->addDocuments(array($liteCoin, $nameCoin));
     $this->assertEquals('litecoin', $type->getDocument(1)->get('name'));
     $this->assertEquals('namecoin', $type->getDocument(2)->get('name'));
     $type->updateDocuments(array(new Document(1, array('name' => 'LiteCoin')), new Document(2, array('name' => 'NameCoin'))));
     $this->assertEquals('LiteCoin', $type->getDocument(1)->get('name'));
     $this->assertEquals('NameCoin', $type->getDocument(2)->get('name'));
     $nameCoin->setType(null);
     // Make sure the type gets set properly if missing
     $type->deleteDocuments(array($liteCoin, $nameCoin));
     $this->setExpectedException('Elastica\\Exception\\NotFoundException');
     $type->getDocument(1);
     $type->getDocument(2);
 }
開發者ID:bungkoko,項目名稱:Elastica,代碼行數:23,代碼來源:ClientTest.php


注:本文中的Elastica\Document::setType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。