当前位置: 首页>>代码示例>>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;未经允许,请勿转载。