/** * Returns a pageable (scan based) result to the given query. * * @param query scan query * @param reader scroll reader * @return a scroll query */ ScrollQuery scanLimit(String query, BytesArray body, long limit, ScrollReader reader) { return new ScrollQuery(this, query, body, limit, reader); }
@Test public void test() throws Exception { RestRepository repository = mockRepository(); ScrollReader scrollReader = Mockito.mock(ScrollReader.class); String query = "/index/type/_search?scroll=10m&etc=etc"; BytesArray body = new BytesArray("{}"); long size = 100; ScrollQuery scrollQuery = new ScrollQuery(repository, query, body, size, scrollReader); Assert.assertTrue(scrollQuery.hasNext()); Assert.assertEquals("value", JsonUtils.query("field").apply(scrollQuery.next()[1])); Assert.assertFalse(scrollQuery.hasNext()); scrollQuery.close(); Stats stats = scrollQuery.stats(); Assert.assertEquals(1, stats.docsReceived); }
/** * Returns a pageable (scan based) result to the given query. * * @param query scan query * @param reader scroll reader * @return a scroll query */ ScrollQuery scanLimit(String query, BytesArray body, long limit, ScrollReader reader) { return new ScrollQuery(this, query, body, limit, reader); }
/** * Returns a pageable (scan based) result to the given query. * * @param query scan query * @param reader scroll reader * @return a scroll query */ ScrollQuery scanLimit(String query, BytesArray body, long limit, ScrollReader reader) { return new ScrollQuery(this, query, body, limit, reader); }
/** * Returns a pageable (scan based) result to the given query. * * @param query scan query * @param reader scroll reader * @return a scroll query */ ScrollQuery scanLimit(String query, BytesArray body, long limit, ScrollReader reader) { return new ScrollQuery(this, query, body, limit, reader); }
/** * Returns a pageable (scan based) result to the given query. * * @param query scan query * @param reader scroll reader * @return a scroll query */ ScrollQuery scanLimit(String query, BytesArray body, long limit, ScrollReader reader) { String[] scrollInfo = client.scan(query, body); String scrollId = scrollInfo[0]; long totalSize = (limit < 1 ? Long.parseLong(scrollInfo[1]) : limit); return new ScrollQuery(this, scrollId, totalSize, reader); }