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


PHP Document::hasVersion方法代码示例

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


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

示例1: testUpdateDocumentWithFieldsSource

 /**
  * @group functional
  */
 public function testUpdateDocumentWithFieldsSource()
 {
     $this->_checkScriptInlineSetting();
     $client = $this->_getClient();
     $index = $client->getIndex('elastica_test');
     $type = $index->getType('update_type');
     $client->setConfigValue('document', array('autoPopulate' => true));
     $newDocument = new Document(null, array('counter' => 5, 'name' => 'Batman'));
     $this->assertFalse($newDocument->hasVersion());
     $response = $type->addDocument($newDocument);
     $responseData = $response->getData();
     $this->assertTrue($newDocument->hasVersion());
     $this->assertArrayHasKey('_version', $responseData, '_version is missing in response data it is weird');
     $this->assertEquals(1, $responseData['_version']);
     $this->assertEquals($responseData['_version'], $newDocument->getVersion());
     $this->assertTrue($newDocument->hasId());
     $script = new Script('ctx._source.counter += count; ctx._source.realName = realName');
     $script->setId($newDocument->getId());
     $script->setParam('count', 7);
     $script->setParam('realName', 'Bruce Wayne');
     $script->setUpsert($newDocument);
     $newDocument->setFieldsSource();
     $response = $type->updateDocument($script);
     $responseData = $response->getData();
     $data = $type->getDocument($newDocument->getId())->getData();
     $this->assertEquals(12, $data['counter']);
     $this->assertEquals('Batman', $data['name']);
     $this->assertEquals('Bruce Wayne', $data['realName']);
     $this->assertTrue($newDocument->hasVersion());
     $this->assertArrayHasKey('_version', $responseData, '_version is missing in response data it is weird');
     $this->assertEquals(2, $responseData['_version']);
     $document = $type->getDocument($newDocument->getId());
 }
开发者ID:bungkoko,项目名称:Elastica,代码行数:36,代码来源:TypeTest.php


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