當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。