Search in sources :

Example 1 with NO_BATCHSIZE

use of org.graylog2.indexer.searches.ScrollCommand.NO_BATCHSIZE in project graylog2-server by Graylog2.

the class SearchesIT method scrollReturnsResultWithSelectiveFields.

@Test
public void scrollReturnsResultWithSelectiveFields() throws Exception {
    importFixture("org/graylog2/indexer/searches/SearchesIT.json");
    when(indexSetRegistry.getForIndices(Collections.singleton("graylog_0"))).thenReturn(Collections.singleton(indexSet));
    final AbsoluteRange range = AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC).withZone(UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC).withZone(UTC));
    final ScrollResult scrollResult = searches.scroll("*", range, 5, 0, Collections.singletonList("source"), null, NO_BATCHSIZE);
    assertThat(scrollResult).isNotNull();
    assertThat(scrollResult.getQueryHash()).isNotEmpty();
    assertThat(scrollResult.totalHits()).isEqualTo(10L);
    final ScrollResult.ScrollChunk firstChunk = scrollResult.nextChunk();
    assertThat(firstChunk).isNotNull();
    assertThat(firstChunk.getMessages()).hasSize(5);
    assertThat(firstChunk.isFirstChunk()).isTrue();
    assertThat(firstChunk.getFields()).containsExactly("source");
}
Also used : AbsoluteRange(org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange) ScrollResult(org.graylog2.indexer.results.ScrollResult) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest) Test(org.junit.Test)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)1 ElasticsearchBaseTest (org.graylog.testing.elasticsearch.ElasticsearchBaseTest)1 ScrollResult (org.graylog2.indexer.results.ScrollResult)1 AbsoluteRange (org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1