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


PHP Type::getDocument方法代码示例

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


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

示例1: testSearchByDocument

 /**
  * @group functional
  */
 public function testSearchByDocument()
 {
     $client = $this->_getClient(array('persistent' => false));
     $index = $client->getIndex('elastica_test');
     $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
     $type = new Type($index, 'mlt_test');
     $type->addDocuments(array(new Document(1, array('visible' => true, 'name' => 'bruce wayne batman')), new Document(2, array('visible' => true, 'name' => 'bruce wayne')), new Document(3, array('visible' => false, 'name' => 'bruce wayne')), new Document(4, array('visible' => true, 'name' => 'batman')), new Document(5, array('visible' => false, 'name' => 'batman')), new Document(6, array('visible' => true, 'name' => 'superman')), new Document(7, array('visible' => true, 'name' => 'spiderman'))));
     $index->refresh();
     $doc = $type->getDocument(1);
     // Return all similar from id
     $mltQuery = new MoreLikeThis();
     $mltQuery->setMinTermFrequency(1);
     $mltQuery->setMinDocFrequency(1);
     $mltQuery->setLike($doc);
     $query = new Query($mltQuery);
     $resultSet = $type->search($query);
     $this->assertEquals(4, $resultSet->count());
     $mltQuery = new MoreLikeThis();
     $mltQuery->setMinTermFrequency(1);
     $mltQuery->setMinDocFrequency(1);
     $mltQuery->setLike($doc);
     $query = new Query\BoolQuery();
     $query->addMust($mltQuery);
     $this->hideDeprecated();
     // Return just the visible similar from id
     $filter = new Query\BoolQuery();
     $filterTerm = new Query\Term();
     $filterTerm->setTerm('visible', true);
     $filter->addMust($filterTerm);
     $query->addFilter($filter);
     $this->showDeprecated();
     $resultSet = $type->search($query);
     $this->assertEquals(2, $resultSet->count());
     // Return all similar from source
     $mltQuery = new MoreLikeThis();
     $mltQuery->setMinTermFrequency(1);
     $mltQuery->setMinDocFrequency(1);
     $mltQuery->setMinimumShouldMatch(90);
     $mltQuery->setLike($type->getDocument(1)->setId(''));
     $query = new Query($mltQuery);
     $resultSet = $type->search($query);
     $this->assertEquals(1, $resultSet->count());
     // Legacy test with filter
     $mltQuery = new MoreLikeThis();
     $mltQuery->setMinTermFrequency(1);
     $mltQuery->setMinDocFrequency(1);
     $mltQuery->setLike($doc);
     $query = new Query\BoolQuery();
     $query->addMust($mltQuery);
     $this->hideDeprecated();
     // Return just the visible similar
     $filter = new BoolFilter();
     $filterTerm = new Term();
     $filterTerm->setTerm('visible', true);
     $filter->addMust($filterTerm);
     $query->addFilter($filter);
     $this->showDeprecated();
     $resultSet = $type->search($query);
     $this->assertEquals(2, $resultSet->count());
 }
开发者ID:makeandship,项目名称:wordpress-fantastic-elasticsearch,代码行数:63,代码来源:MoreLikeThisTest.php

示例2: setUp

 protected function setUp()
 {
     $typeName = Cache::TYPE_NAME;
     $this->type = $this->prophesize('\\Elastica\\Type');
     $this->type->request(Argument::any(), Argument::cetera())->willReturn(true);
     $this->type->getName()->willReturn($typeName);
     $this->index = $this->prophesize('\\Elastica\\Index');
     $this->index->getType($typeName)->willReturn($this->type->reveal());
     $this->index->exists()->willReturn(true);
     $nsDoc = new Document('DoctrineNamespaceCacheKey[]', [Cache::VALUE_FIELD => serialize($this->namespaceId)]);
     $this->type->getIndex()->willReturn($this->index->reveal());
     $this->type->getDocument("DoctrineNamespaceCacheKey[]")->willReturn($nsDoc);
     $this->client = $this->prophesize('\\Elastica\\Client');
     $this->client->getIndex($this->indexName)->willReturn($this->index->reveal());
     $this->cache = new Cache($this->client->reveal(), ['index' => $this->indexName]);
 }
开发者ID:basster,项目名称:doctrine-elastica-cache,代码行数:16,代码来源:CacheTest.php

示例3: removeCities

 /**
  * @param array $removeCities
  */
 public function removeCities($removeCities)
 {
     foreach ($removeCities as $departmentId => $newCities) {
         $document = $this->departmentType->getDocument($departmentId);
         $data = $document->getData();
         if (isset($data['citiesIds'])) {
             $cities = $data['citiesIds'];
             foreach ($newCities as $newCity) {
                 unset($cities[$newCity]);
             }
             $data['citiesIds'] = $cities;
             $document->setData($data);
             $this->departmentType->updateDocument($document);
         }
     }
 }
开发者ID:blab2015,项目名称:seh,代码行数:19,代码来源:AutocompleteManager.php

示例4: addDocumentToElastic

 /**
  * @param array $document
  * @param string $type
  * @throws \Exception
  */
 protected function addDocumentToElastic(array $document, $type = 'issue')
 {
     switch ($type) {
         case 'issue':
             if (isset($document['custom_fields'])) {
                 foreach ($document['custom_fields'] as $customField) {
                     switch ($customField['id']) {
                         case 4:
                             $document['typo3_version'] = isset($customField['value']) ? $customField['value'] : '-';
                             break;
                         case 5:
                             $document['php_version'] = isset($customField['value']) ? $customField['value'] : '-';
                             break;
                         case 8:
                             $document['complexity'] = isset($customField['value']) ? $customField['value'] : '-';
                             break;
                         case 15:
                             $document['isregression'] = isset($customField['value']) ? true : false;
                             break;
                         case 18:
                             $document['focus']['name'] = isset($customField['value']) ? $customField['value'] : '-';
                             break;
                         default:
                     }
                 }
             }
             $document['updated_on'] = $this->fixDateFormat($document['updated_on']);
             $document['created_on'] = $this->fixDateFormat($document['created_on']);
             $type = new Elastica\Type($this->elasticIndex, 'issue');
             try {
                 $testIfDocExists = $type->getDocument($document['id']);
             } catch (\Exception $e) {
                 $message = new \WMDB\Forger\Utilities\Slack\Message();
                 $message->sendMessage($document);
             }
             break;
         case 'review':
             $type = new Elastica\Type($this->elasticIndex, 'review');
             break;
         case 'user':
             $type = new Elastica\Type($this->elasticIndex, 'user');
             break;
         default:
     }
     #\TYPO3\Flow\var_dump($type);
     $doc = new Elastica\Document($document['id'], $document);
     #\TYPO3\Flow\var_dump($doc);
     $type->addDocument($doc);
     #sleep(1);
 }
开发者ID:khuppenbauer,项目名称:WMDB.Forger,代码行数:55,代码来源:ForgeImportCommandController.php

示例5: findById

 /**
  * @inheritdoc
  */
 public function findById(\string $id) : ProductView
 {
     $result = $this->type->getDocument($id);
     $product = $this->transformer->transformObject($result->getData());
     return $product;
 }
开发者ID:igaponov,项目名称:shop,代码行数:9,代码来源:ProductViewRepository.php

示例6: testGetDocumentWithFieldsSelection

 /**
  * Test to see if Elastica_Type::getDocument() is properly using
  * the fields array when available instead of _source.
  *
  * @group functional
  */
 public function testGetDocumentWithFieldsSelection()
 {
     $index = $this->_createIndex();
     $type = new Type($index, 'test');
     $type->addDocument(new Document(1, array('name' => 'loris', 'country' => 'FR', 'email' => 'test@test.com')));
     $index->refresh();
     $document = $type->getDocument(1, array('fields' => 'name,email'));
     $data = $document->getData();
     $this->assertArrayHasKey('name', $data);
     $this->assertArrayHasKey('email', $data);
     $this->assertArrayNotHasKey('country', $data);
 }
开发者ID:bungkoko,项目名称:Elastica,代码行数:18,代码来源:TypeTest.php

示例7: testMoreLikeThisApi

 public function testMoreLikeThisApi()
 {
     $client = new Client(array('persistent' => false));
     $index = $client->getIndex('elastica_test');
     $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
     $type = new Type($index, 'mlt_test');
     $type->addDocument(new Document(1, array('visible' => true, 'name' => 'bruce wayne batman')));
     $type->addDocument(new Document(2, array('visible' => true, 'name' => 'bruce wayne')));
     $type->addDocument(new Document(3, array('visible' => false, 'name' => 'bruce wayne')));
     $type->addDocument(new Document(4, array('visible' => true, 'name' => 'batman')));
     $type->addDocument(new Document(5, array('visible' => false, 'name' => 'batman')));
     $type->addDocument(new Document(6, array('visible' => true, 'name' => 'superman')));
     $type->addDocument(new Document(7, array('visible' => true, 'name' => 'spiderman')));
     $index->refresh();
     $document = $type->getDocument(1);
     // Return all similar
     $resultSet = $type->moreLikeThis($document, array('min_term_freq' => '1', 'min_doc_freq' => '1'));
     $this->assertEquals(4, $resultSet->count());
     // Return just the visible similar
     $query = new Query();
     $filterTerm = new Term();
     $filterTerm->setTerm('visible', true);
     $query->setFilter($filterTerm);
     $resultSet = $type->moreLikeThis($document, array('min_term_freq' => '1', 'min_doc_freq' => '1'), $query);
     $this->assertEquals(2, $resultSet->count());
 }
开发者ID:kskod,项目名称:Elastica,代码行数:26,代码来源:TypeTest.php


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