use of io.searchbox.core.search.aggregation.MetricAggregation in project graylog2-server by Graylog2.
the class ESEventListTest method testSortingOfStreamsInDoExtractResult.
@Test
public void testSortingOfStreamsInDoExtractResult() {
final ESEventList esEventList = new TestESEventList();
final SearchJob searchJob = mock(SearchJob.class);
final Query query = mock(Query.class);
final SearchResult searchResult = mock(SearchResult.class);
final MetricAggregation metricAggregation = mock(MetricAggregation.class);
final ESGeneratedQueryContext queryContext = mock(ESGeneratedQueryContext.class);
final EventList eventList = EventList.builder().id("search-type-id").streams(ImmutableSet.of("stream-id-1", "stream-id-2")).build();
final EventList.Result eventResult = (EventList.Result) esEventList.doExtractResult(searchJob, query, eventList, searchResult, metricAggregation, queryContext);
assertThat(eventResult.events()).containsExactly(eventSummary("find-1", ImmutableSet.of("stream-id-1")), eventSummary("find-2", ImmutableSet.of("stream-id-2")), eventSummary("find-3", ImmutableSet.of("stream-id-1", "stream-id-2")));
}
use of io.searchbox.core.search.aggregation.MetricAggregation in project graylog2-server by Graylog2.
the class ESPivotTest method searchResultForAllMessagesIncludesPivotTimerangeForNoDocuments.
@Test
public void searchResultForAllMessagesIncludesPivotTimerangeForNoDocuments() throws InvalidRangeParametersException {
DateTimeUtils.setCurrentMillisFixed(1578584665408L);
final long documentCount = 0;
when(queryResult.getTotal()).thenReturn(documentCount);
final MetricAggregation mockMetricAggregation = createTimestampRangeAggregations(null, null);
when(queryResult.getAggregations()).thenReturn(mockMetricAggregation);
when(query.effectiveTimeRange(pivot)).thenReturn(RelativeRange.create(0));
final SearchType.Result result = this.esPivot.doExtractResult(job, query, pivot, queryResult, aggregations, queryContext);
final PivotResult pivotResult = (PivotResult) result;
assertThat(pivotResult.effectiveTimerange()).isEqualTo(AbsoluteRange.create(DateTime.parse("1970-01-01T00:00:00.000Z"), DateTime.parse("2020-01-09T15:44:25.408Z")));
}
use of io.searchbox.core.search.aggregation.MetricAggregation in project graylog2-server by Graylog2.
the class ESPivotTest method searchResultIncludesDocumentCount.
@Test
public void searchResultIncludesDocumentCount() throws InvalidRangeParametersException {
final long documentCount = 424242;
when(queryResult.getTotal()).thenReturn(documentCount);
final MetricAggregation mockMetricAggregation = createTimestampRangeAggregations((double) new Date().getTime(), (double) new Date().getTime());
when(queryResult.getAggregations()).thenReturn(mockMetricAggregation);
when(query.effectiveTimeRange(pivot)).thenReturn(RelativeRange.create(300));
final SearchType.Result result = this.esPivot.doExtractResult(job, query, pivot, queryResult, aggregations, queryContext);
final PivotResult pivotResult = (PivotResult) result;
assertThat(pivotResult.total()).isEqualTo(documentCount);
}
use of io.searchbox.core.search.aggregation.MetricAggregation in project graylog2-server by Graylog2.
the class ESPivotTest method searchResultForAllMessagesIncludesTimerangeOfDocuments.
@Test
public void searchResultForAllMessagesIncludesTimerangeOfDocuments() throws InvalidRangeParametersException {
DateTimeUtils.setCurrentMillisFixed(1578584665408L);
final long documentCount = 424242;
when(queryResult.getTotal()).thenReturn(documentCount);
final MetricAggregation mockMetricAggregation = createTimestampRangeAggregations((double) new Date(1547303022000L).getTime(), (double) new Date(1578040943000L).getTime());
when(queryResult.getAggregations()).thenReturn(mockMetricAggregation);
when(query.effectiveTimeRange(pivot)).thenReturn(RelativeRange.create(0));
final SearchType.Result result = this.esPivot.doExtractResult(job, query, pivot, queryResult, aggregations, queryContext);
final PivotResult pivotResult = (PivotResult) result;
assertThat(pivotResult.effectiveTimerange()).isEqualTo(AbsoluteRange.create(DateTime.parse("2019-01-12T14:23:42.000Z"), DateTime.parse("2020-01-03T08:42:23.000Z")));
DateTimeUtils.setCurrentMillisSystem();
}
use of io.searchbox.core.search.aggregation.MetricAggregation in project graylog2-server by Graylog2.
the class ESPivotTest method searchResultIncludesTimerangeOfPivot.
@Test
public void searchResultIncludesTimerangeOfPivot() throws InvalidRangeParametersException {
DateTimeUtils.setCurrentMillisFixed(1578584665408L);
final long documentCount = 424242;
when(queryResult.getTotal()).thenReturn(documentCount);
final MetricAggregation mockMetricAggregation = createTimestampRangeAggregations((double) new Date().getTime(), (double) new Date().getTime());
when(queryResult.getAggregations()).thenReturn(mockMetricAggregation);
when(query.effectiveTimeRange(pivot)).thenReturn(RelativeRange.create(300));
final SearchType.Result result = this.esPivot.doExtractResult(job, query, pivot, queryResult, aggregations, queryContext);
final PivotResult pivotResult = (PivotResult) result;
assertThat(pivotResult.effectiveTimerange()).isEqualTo(AbsoluteRange.create(DateTime.parse("2020-01-09T15:39:25.408Z"), DateTime.parse("2020-01-09T15:44:25.408Z")));
}
Aggregations