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


PHP Document::setData方法代码示例

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


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

 /**
  * Partial Update
  *
  * @param  string  $docId
  * @param  array    $data
  * @param  integer  $version
  *
  * @throws IndexingException
  *
  * @return null
  */
 public function update($docId, array $data, $version = 1)
 {
     $document = new Document();
     $document->setData($data);
     $document->setId($docId);
     $document->setDocAsUpsert(true);
     try {
         $this->getType($version)->updateDocument($document);
     } catch (\Exception $e) {
         throw new IndexingException('Throw exception while updating', $e->getCode(), $e);
     }
 }
开发者ID:biberlabs,项目名称:zf2-boilerplate,代码行数:23,代码来源:AbstractIndexService.php

示例4: populate

 /**
  * Insert the repository objects in the type index
  *
  * @param \Closure $loggerClosure
  * @param array    $options
  */
 public function populate(\Closure $loggerClosure = null, array $options = array())
 {
     if ($loggerClosure) {
         $loggerClosure('Indexing movies');
     }
     $allMovies = $this->movieManager->getAllMovies();
     $languages = $this->getLanguagesAvailable();
     foreach ($allMovies as $movie) {
         $document = new Document();
         $id = $movie->getId();
         $document->setId($id);
         $titleFr = $this->movieManager->getMovieTitleInLocale($id, $languages['fr']);
         $titleEn = $this->movieManager->getMovieTitleInLocale($id, $languages['en']);
         //            $titleEn = $this->movieManager->getMovieTitleInLocale($id, 'en');
         //            $titleFr = $this->movieManager->getMovieTitleInLocale($id, 'fr');
         $document->setData(array('id' => $id, 'title_fr' => $titleFr['title'], 'title_en' => $titleEn['title']));
         $this->movieType->addDocuments(array($document));
     }
 }
开发者ID:ChristWood,项目名称:videoCollection,代码行数:25,代码来源:TitleProvider.php

示例5: 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

示例6: _populateDocumentFieldsFromResponse

 /**
  * @param \Elastica\Response $response
  * @param \Elastica\Document $document
  * @param string             $fields   Array of field names to be populated or '_source' if whole document data should be updated
  */
 protected function _populateDocumentFieldsFromResponse(Response $response, Document $document, $fields)
 {
     $responseData = $response->getData();
     if ('_source' == $fields) {
         if (isset($responseData['get']['_source']) && is_array($responseData['get']['_source'])) {
             $document->setData($responseData['get']['_source']);
         }
     } else {
         $keys = explode(',', $fields);
         $data = $document->getData();
         foreach ($keys as $key) {
             if (isset($responseData['get']['fields'][$key])) {
                 $data[$key] = $responseData['get']['fields'][$key];
             } elseif (isset($data[$key])) {
                 unset($data[$key]);
             }
         }
         $document->setData($data);
     }
 }
开发者ID:backplane,项目名称:elastica,代码行数:25,代码来源:Client.php

示例7: logStringQuery

 /**
  * {@inheritdoc}
  */
 public function logStringQuery($searchTerm, $ipAddress)
 {
     $document = new Document();
     $document->setData(array('search_term' => $searchTerm, 'ip_address' => $ipAddress));
     $this->type->addDocuments(array($document));
 }
开发者ID:lingoda,项目名称:Sylius,代码行数:9,代码来源:ElasticsearchQueryLogger.php

示例8: addObjects

 /**
  * Uses _bulk to send documents to the server
  *
  * @param objects[] $objects
  * @return \Elastica\Bulk\ResponseSet
  * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
  */
 public function addObjects(array $objects)
 {
     if (!isset($this->_serializer)) {
         throw new RuntimeException('No serializer defined');
     }
     $docs = array();
     foreach ($objects as $object) {
         $data = call_user_func($this->_serializer, $object);
         $doc = new Document();
         $doc->setData($data);
         $doc->setType($this->getName());
         $docs[] = $doc;
     }
     return $this->getIndex()->addDocuments($docs);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:22,代码来源:Type.php

示例9: testUpsert

 /**
  * @group unit
  */
 public function testUpsert()
 {
     $document = new Document();
     $upsert = new Document();
     $upsert->setData(array('someproperty' => 'somevalue'));
     $this->assertFalse($document->hasUpsert());
     $document->setUpsert($upsert);
     $this->assertTrue($document->hasUpsert());
     $this->assertSame($upsert, $document->getUpsert());
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:13,代码来源:DocumentTest.php

示例10: testSetData

 public function testSetData()
 {
     $doc = new Document();
     $returnValue = $doc->setData(array('data'));
     $this->assertInstanceOf('Elastica\\Document', $returnValue);
 }
开发者ID:kskod,项目名称:Elastica,代码行数:6,代码来源:DocumentTest.php

示例11: addObject

 public function addObject($object, Document $doc = null)
 {
     if (!isset($this->_serializer)) {
         throw new RuntimeException('No serializer defined');
     }
     $data = call_user_func($this->_serializer, $object);
     if (!$doc) {
         $doc = new Document();
     }
     $doc->setData($data);
     return $this->addDocument($doc);
 }
开发者ID:kskod,项目名称:Elastica,代码行数:12,代码来源:Type.php


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