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


PHP Document::getId方法代码示例

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


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

示例1: moreLikeThis

 /**
  * More like this query based on the given object
  *
  * The id in the given object has to be set
  *
  * @param  \Elastica\Document           $doc    Document to query for similar objects
  * @param  array                       $params OPTIONAL Additional arguments for the query
  * @param  string|array|\Elastica\Query $query  OPTIONAL Query to filter the moreLikeThis results
  * @return \Elastica\ResultSet          ResultSet with all results inside
  * @link http://www.elasticsearch.org/guide/reference/api/more-like-this.html
  */
 public function moreLikeThis(Document $doc, $params = array(), $query = array())
 {
     $path = $doc->getId() . '/_mlt';
     $query = Query::create($query);
     $response = $this->request($path, Request::GET, $query->toArray(), $params);
     return new ResultSet($response, $query);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:18,代码来源:Type.php

示例2: deleteDocument

 /**
  * @param \Elastica\Document $document
  *
  * @return \Elastica\Response
  */
 public function deleteDocument(Document $document)
 {
     $options = $document->getOptions(array('version', 'version_type', 'routing', 'parent', 'replication', 'consistency', 'refresh', 'timeout'));
     return $this->deleteById($document->getId(), $options);
 }
开发者ID:levijackson,项目名称:Elastica,代码行数:10,代码来源:Type.php

示例3: updateDocument

 /**
  * Update document, using update script. Requires elasticsearch >= 0.19.0
  *
  * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html
  * @throws \Elastica\Exception\InvalidException
  *
  * @param  \Elastica\Document|\Elastica\Script $data    Document with update data
  * @param  array                               $options array of query params to use for query. For possible options check es api
  * @return \Elastica\Response
  */
 public function updateDocument($data, array $options = array())
 {
     if (!$data instanceof Document && !$data instanceof Script) {
         throw new \InvalidArgumentException("Data should be a Document or Script");
     }
     if (!$data->hasId()) {
         throw new InvalidException('Document or Script id is not set');
     }
     $id = urlencode($data->getId());
     return $this->getIndex()->getClient()->updateDocument($id, $data, $this->getIndex()->getName(), $this->getName(), $options);
 }
开发者ID:backplane,项目名称:elastica,代码行数:21,代码来源:Type.php

示例4: testAddDocumentAutoGeneratedId

 /**
  * @group functional
  */
 public function testAddDocumentAutoGeneratedId()
 {
     $index = $this->_createIndex();
     $type = $index->getType('elastica_type');
     $document = new Document();
     $document->setAutoPopulate();
     $document->set('name', 'ruflin');
     $this->assertEquals('', $document->getId());
     $this->assertFalse($document->hasId());
     $type->addDocument($document);
     $this->assertNotEquals('', $document->getId());
     $this->assertTrue($document->hasId());
     $foundDoc = $type->getDocument($document->getId());
     $this->assertInstanceOf('Elastica\\Document', $foundDoc);
     $this->assertEquals($document->getId(), $foundDoc->getId());
     $data = $foundDoc->getData();
     $this->assertArrayHasKey('name', $data);
     $this->assertEquals('ruflin', $data['name']);
 }
开发者ID:bungkoko,项目名称:Elastica,代码行数:22,代码来源:TypeTest.php


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