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


PHP Type::deleteById方法代码示例

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


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

示例1: cleanElasticSearchIndex

 /**
  * remove the eav deleted products from elasticsearch index
  *
  * @param array $productIds
  */
 public function cleanElasticSearchIndex(array $productIds)
 {
     foreach ($productIds as $productId) {
         try {
             $this->_type->deleteById($productId);
         } catch (Exception $e) {
             //continue if $productId not found
             //TODO Logging
             continue;
         }
     }
 }
开发者ID:vadimjustus,项目名称:m2-elasticsearch,代码行数:17,代码来源:Elastic.php

示例2: removeIndexById

 /**
  * @param integer $id
  * @param Type $type
  */
 public function removeIndexById($id, Type $type)
 {
     try {
         $type->deleteById($id);
     } catch (\InvalidArgumentException $e) {
     } catch (NotFoundException $e) {
     }
 }
开发者ID:leapt,项目名称:elastica-bundle,代码行数:12,代码来源:AbstractIndexer.php

示例3: testOptimize

 /**
  * @group functional
  */
 public function testOptimize()
 {
     $index = $this->_createIndex();
     $type = new Type($index, 'optimize');
     $docs = array();
     $docs[] = new Document(1, array('foo' => 'bar'));
     $docs[] = new Document(2, array('foo' => 'bar'));
     $type->addDocuments($docs);
     $index->refresh();
     $stats = $index->getStats()->getData();
     $this->assertEquals(0, $stats['_all']['primaries']['docs']['deleted']);
     $type->deleteById(1);
     $index->refresh();
     $stats = $index->getStats()->getData();
     $this->assertEquals(1, $stats['_all']['primaries']['docs']['deleted']);
     $index->optimize(array('max_num_segments' => 1));
     $stats = $index->getStats()->getData();
     $this->assertEquals(0, $stats['_all']['primaries']['docs']['deleted']);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.0,代码行数:22,代码来源:IndexTest.php

示例4: testDeleteById

 /**
  * @group functional
  */
 public function testDeleteById()
 {
     $index = $this->_createIndex();
     $type = new Type($index, 'user');
     // Adds hans, john and rolf to the index
     $docs = array(new Document(1, array('username' => 'hans', 'test' => array('2', '3', '5'))), new Document(2, array('username' => 'john', 'test' => array('1', '3', '6'))), new Document(3, array('username' => 'rolf', 'test' => array('2', '3', '7'))), new Document('foo/bar', array('username' => 'georg', 'test' => array('4', '2', '5'))));
     $type->addDocuments($docs);
     $index->refresh();
     // sanity check for rolf
     $resultSet = $type->search('rolf');
     $this->assertEquals(1, $resultSet->count());
     $data = $resultSet->current()->getData();
     $this->assertEquals('rolf', $data['username']);
     // delete rolf
     $type->deleteById(3);
     $index->refresh();
     // rolf should no longer be there
     $resultSet = $type->search('rolf');
     $this->assertEquals(0, $resultSet->count());
     // sanity check for id with slash
     $resultSet = $type->search('georg');
     $this->assertEquals(1, $resultSet->count());
     // delete georg
     $type->deleteById('foo/bar');
     $index->refresh();
     // georg should no longer be there
     $resultSet = $type->search('georg');
     $this->assertEquals(0, $resultSet->count());
     // it should not be possible to delete the entire type with this method
     try {
         $type->deleteById('');
         $this->fail('Delete with empty string id should fail');
     } catch (\InvalidArgumentException $e) {
         $this->assertTrue(true);
     }
     try {
         $type->deleteById(' ');
         $this->fail('Delete with one space string id should fail');
     } catch (\InvalidArgumentException $e) {
         $this->assertTrue(true);
     }
     try {
         $type->deleteById(null);
         $this->fail('Delete with null id should fail');
     } catch (\InvalidArgumentException $e) {
         $this->assertTrue(true);
     }
     try {
         $type->deleteById(array());
         $this->fail('Delete with empty array id should fail');
     } catch (\InvalidArgumentException $e) {
         $this->assertTrue(true);
     }
     try {
         $type->deleteById('*');
         $this->fail('Delete request should fail because of invalid id: *');
     } catch (NotFoundException $e) {
         $this->assertTrue(true);
     }
     try {
         $type->deleteById('*:*');
         $this->fail('Delete request should fail because document with id *.* does not exist');
     } catch (NotFoundException $e) {
         $this->assertTrue(true);
     }
     try {
         $type->deleteById('!');
         $this->fail('Delete request should fail because document with id ! does not exist');
     } catch (NotFoundException $e) {
         $this->assertTrue(true);
     }
     $index->refresh();
     // rolf should no longer be there
     $resultSet = $type->search('john');
     $this->assertEquals(1, $resultSet->count());
 }
开发者ID:bungkoko,项目名称:Elastica,代码行数:79,代码来源:TypeTest.php

示例5: doDeleteReturnsFalseWhenNotFound

 /**
  * @test
  */
 public function doDeleteReturnsFalseWhenNotFound()
 {
     $id = 1;
     $this->type->deleteById($this->getCacheId($id))->shouldBeCalled()->willThrow('\\Elastica\\Exception\\NotFoundException');
     self::assertFalse($this->cache->delete($id));
 }
开发者ID:basster,项目名称:doctrine-elastica-cache,代码行数:9,代码来源:CacheTest.php

示例6: removeHotel

 /**
  * @param Hotel $hotel
  *
  * @return $this
  */
 public function removeHotel($hotel)
 {
     $this->hotelType->deleteById($hotel->getId());
 }
开发者ID:blab2015,项目名称:seh,代码行数:9,代码来源:AutocompleteManager.php


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