當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Document::setIndex方法代碼示例

本文整理匯總了PHP中Elastica\Document::setIndex方法的典型用法代碼示例。如果您正苦於以下問題:PHP Document::setIndex方法的具體用法?PHP Document::setIndex怎麽用?PHP Document::setIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Elastica\Document的用法示例。


在下文中一共展示了Document::setIndex方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetOptions

 public function testGetOptions()
 {
     $document = new Document();
     $document->setIndex('index');
     $document->setOpType('create');
     $document->setParent('2');
     $document->setId(1);
     $options = $document->getOptions(array('index', 'type', 'id', 'parent'));
     $this->assertInternalType('array', $options);
     $this->assertEquals(3, count($options));
     $this->assertArrayHasKey('index', $options);
     $this->assertArrayHasKey('id', $options);
     $this->assertArrayHasKey('parent', $options);
     $this->assertEquals('index', $options['index']);
     $this->assertEquals(1, $options['id']);
     $this->assertEquals('2', $options['parent']);
     $this->assertArrayNotHasKey('type', $options);
     $this->assertArrayNotHasKey('op_type', $options);
     $this->assertArrayNotHasKey('_index', $options);
     $this->assertArrayNotHasKey('_id', $options);
     $this->assertArrayNotHasKey('_parent', $options);
     $options = $document->getOptions(array('parent', 'op_type', 'percolate'), true);
     $this->assertInternalType('array', $options);
     $this->assertEquals(2, count($options));
     $this->assertArrayHasKey('_parent', $options);
     $this->assertArrayHasKey('_op_type', $options);
     $this->assertEquals('2', $options['_parent']);
     $this->assertEquals('create', $options['_op_type']);
     $this->assertArrayNotHasKey('percolate', $options);
     $this->assertArrayNotHasKey('op_type', $options);
     $this->assertArrayNotHasKey('parent', $options);
 }
開發者ID:kskod,項目名稱:Elastica,代碼行數:32,代碼來源:DocumentTest.php

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

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

示例4: __construct

 /**
  * ElasticaHelper constructor.
  *
  * @param string $gameVersion
  * @param string $indexName
  * @param int    $magicNumber
  */
 public function __construct($gameVersion, $indexName, $magicNumber = 500)
 {
     $docPrototype = new Document();
     $docPrototype->setIndex($indexName)->setType('user:' . $gameVersion);
     $this->documentFactory = new DocumentFactory($docPrototype);
     $this->elastica = $this->makeElastica();
     $this->magicNumber = $magicNumber;
     $this->errorHandler = function (\Exception $exception) {
         error_log(print_r($exception->getMessage(), true), 3, CONFIG_DIR . '/elastica.error');
     };
 }
開發者ID:jiangyu7408,項目名稱:notification,代碼行數:18,代碼來源:ElasticaHelper.php

示例5: deleteDocuments

 protected function deleteDocuments()
 {
     dump(__METHOD__);
     require_once __DIR__ . '/UserProvider.php';
     $userList = (new \UserProvider())->listUser();
     $documents = array_map(function (User $user) {
         $document = new Document($user->snsid);
         $document->setIndex($this->getIndexName())->setType($this->getTypeName());
         return $document;
     }, $userList);
     $responseSet = $this->getClient()->getIndex($this->getIndexName())->deleteDocuments($documents);
     foreach ($responseSet as $response) {
         $data = $response->getData();
         $this->assertEquals(3, $data['_version']);
         $action = $response->getAction();
         $this->assertEquals('delete', $action->getOpType());
     }
 }
開發者ID:jiangyu7408,項目名稱:notification,代碼行數:18,代碼來源:MappingTest.php

示例6: testBulkIndex

 /**
  * Test bulk operations on Index.
  *
  * @group functional
  */
 public function testBulkIndex()
 {
     $index = $this->_getClient()->getIndex('cryptocurrencies');
     $anonCoin = new Document(1, array('name' => 'anoncoin'), 'altcoin');
     $ixCoin = new Document(2, array('name' => 'ixcoin'), 'altcoin');
     $index->addDocuments(array($anonCoin, $ixCoin));
     $this->assertEquals('anoncoin', $index->getType('altcoin')->getDocument(1)->get('name'));
     $this->assertEquals('ixcoin', $index->getType('altcoin')->getDocument(2)->get('name'));
     $index->updateDocuments(array(new Document(1, array('name' => 'AnonCoin'), 'altcoin'), new Document(2, array('name' => 'iXcoin'), 'altcoin')));
     $this->assertEquals('AnonCoin', $index->getType('altcoin')->getDocument(1)->get('name'));
     $this->assertEquals('iXcoin', $index->getType('altcoin')->getDocument(2)->get('name'));
     $ixCoin->setIndex(null);
     // Make sure the index gets set properly if missing
     $index->deleteDocuments(array($anonCoin, $ixCoin));
     $this->setExpectedException('Elastica\\Exception\\NotFoundException');
     $index->getType('altcoin')->getDocument(1);
     $index->getType('altcoin')->getDocument(2);
 }
開發者ID:bungkoko,項目名稱:Elastica,代碼行數:23,代碼來源:ClientTest.php

示例7: __construct

 /**
  * Factory constructor.
  */
 public function __construct()
 {
     $docPrototype = new Document();
     $docPrototype->setIndex(ELASTIC_SEARCH_INDEX)->setType('user:unknown');
     $this->documentFactory = new DocumentFactory($docPrototype);
 }
開發者ID:jiangyu7408,項目名稱:notification,代碼行數:9,代碼來源:Factory.php

示例8: setUpBeforeClass

 /**
  *
  */
 public static function setUpBeforeClass()
 {
     require_once __DIR__ . '/../ES/UserProvider.php';
     self::$documentPrototype = new Document();
     self::$documentPrototype->setIndex('farm')->setType('user:tw');
 }
開發者ID:jiangyu7408,項目名稱:notification,代碼行數:9,代碼來源:ElasticSearchDocumentFactoryTest.php


注:本文中的Elastica\Document::setIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。