public function testSearchScroll()
 {
     $this->createIndex();
     $data = array('name' => 'test' . rand(100, 10000), 'value' => 'myTestVal' . rand(100, 10000));
     $this->createDocument(self::TYPE, $data);
     $data = array('name' => 'test' . rand(100, 10000), 'value' => 'myTestVal' . rand(100, 10000));
     $this->createDocument(self::TYPE, $data);
     $data = array('name' => 'test' . rand(100, 10000), 'value' => 'myTestVal' . rand(100, 10000));
     $this->createDocument(self::TYPE, $data);
     $data = array('name' => 'test' . rand(100, 10000), 'value' => 'myTestVal' . rand(100, 10000));
     $this->createDocument(self::TYPE, $data);
     $this->refreshIndex();
     $searchRequest = new SearchRequest(ES_INDEX, self::TYPE, $this->getSerializer());
     $query = ["query" => ["match_all" => []]];
     $searchRequest->setBody($query);
     $searchRequest->setParameter('scroll', '1m');
     $searchRequest->setParameter('search_type', 'scan');
     /** @var SearchResponse $response */
     $response = $this->getClient()->send($searchRequest);
     $responseData = $response->getData()->getGatewayValue();
     $this->assertTrue(isset($responseData['_scroll_id']));
     $scrollRequest = new SearchScrollRequest(ES_INDEX, self::TYPE, $this->getSerializer());
     $scrollRequest->setScroll('1m');
     $scrollRequest->setScrollId($responseData['_scroll_id']);
     /** @var SearchResponse $responseScroll */
     $responseScroll = $this->getClient()->send($scrollRequest);
     $scrollData = $responseScroll->getData()->getGatewayValue();
     $scrollHits = $responseScroll->getHitsHits();
     $this->assertTrue(isset($scrollData['_scroll_id']));
     $this->assertGreaterThan(5, strlen($scrollData['_scroll_id']));
     $this->assertCount(4, $scrollHits);
 }
Esempio n. 2
0
 public function testConstructorWithJmsSerializer()
 {
     $this->serializer = $this->getMockBuilder('Elastification\\Client\\Serializer\\JmsSerializer')->disableOriginalConstructor()->getMock();
     $request = new SearchRequest(self::INDEX, self::TYPE, $this->serializer);
     $params = $request->getSerializerParams();
     $this->assertSame($params['index'], self::INDEX);
     $this->assertSame($params['type'], self::TYPE);
 }