}
esRequest.addAggregation(AggregationBuilders.min(facetNameAndField).field(facetNameAndField));
Min minValue = esRequest.get().getAggregations().get(facetNameAndField);
- return (long) minValue.getValue();
+ Double actualValue = minValue.getValue();
+ if (actualValue.isInfinite()) {
+ return Long.MIN_VALUE;
+ } else {
+ return actualValue.longValue();
+ }
}
private AggregationBuilder createAssigneesFacet(IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder queryBuilder) {
import javax.annotation.Nullable;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
entry("2016-01-01T01:00:00+0000", 0L));
}
+ @Test
+ public void facet_on_created_at_without_issues() throws Exception {
+ SearchOptions SearchOptions = new SearchOptions().addFacets("createdAt");
+
+ Map<String, Long> createdAt = index.search(IssueQuery.builder().build(),
+ SearchOptions).getFacets().get("createdAt");
+ assertThat(createdAt).isEmpty();
+ }
+
protected SearchOptions fixtureForCreatedAtFacet() {
ComponentDto project = ComponentTesting.newProjectDto();
ComponentDto file = ComponentTesting.newFileDto(project);