当前位置: 首页>>代码示例>>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;未经允许,请勿转载。