예제 #1
0
 public function testCountWithBody()
 {
     $this->createIndex();
     $data = array('name' => 'test', 'value' => 'myTestVal' . rand(100, 10000));
     $this->createDocument(self::TYPE, $data);
     $data = array('name' => 'test', 'value' => 'myTestVal' . rand(100, 10000));
     $this->createDocument(self::TYPE, $data);
     $data = array('name' => 'mega', 'value' => 'myTestVal' . rand(100, 10000));
     $this->createDocument(self::TYPE, $data);
     $this->refreshIndex();
     $countRequest = new CountRequest(ES_INDEX, self::TYPE, $this->getSerializer());
     $countRequest->setBody(array('term' => array('name' => 'test')));
     /** @var CountResponse $response */
     $response = $this->getClient()->send($countRequest);
     $this->assertSame(2, $response->getCount());
     $shards = $response->getShards();
     $this->assertTrue(isset($shards['total']));
     $this->assertTrue(isset($shards['successful']));
     $this->assertTrue(isset($shards['failed']));
 }
예제 #2
0
 public function testConstructorWithJmsSerializer()
 {
     $this->serializer = $this->getMockBuilder('Elastification\\Client\\Serializer\\JmsSerializer')->disableOriginalConstructor()->getMock();
     $request = new CountRequest(self::INDEX, self::TYPE, $this->serializer);
     $params = $request->getSerializerParams();
     $this->assertSame($params['index'], self::INDEX);
     $this->assertSame($params['type'], self::TYPE);
 }