/**
  * @param string $indexName The index against which bulk operations will be performed
  * @param string $type The type against which bulk operations will be performed
  *
  * @return Bulk A Bulk instance configured with the given index and type
  */
 public function createBulk($indexName, $type)
 {
     $bulk = new Bulk($this->elasticSearchClient, $indexName, $type);
     if ($this->eventDispatcher) {
         $bulk->setEventDispatcher($this->eventDispatcher);
     }
     return $bulk;
 }
 public function testItShouldRaiseAnExceptionIfSomeItemsFail()
 {
     $result = new \stdClass();
     $result->errors = ['qux', 'quux'];
     $this->client->expects($this->once())->method('bulk')->willReturn($result);
     $this->setExpectedException('CascadeEnergy\\ElasticSearch\\Exceptions\\PartialFailureException');
     $this->bulk->addItem('idFoo', 'foo');
     $this->bulk->flush();
 }
 public function testItShouldEmptyTheItemListOnClear()
 {
     $this->bulk->addItem('idfoo', 'foo');
     $this->assertAttributeEquals(1, 'itemCount', $this->bulk);
     $this->bulk->clear();
     $this->assertAttributeEquals(0, 'itemCount', $this->bulk);
 }