count date histo using the wrong counts aggregator to return results when using time based setting interval

This commit is contained in:
kimchy 2011-03-02 03:13:25 +02:00
parent 3361a9365b
commit bb1668c2b7
2 changed files with 9 additions and 2 deletions

View File

@ -115,8 +115,6 @@ public class CountDateHistogramFacetCollector extends AbstractFacetCollector {
public static class IntervalDateHistogramProc extends DateHistogramProc {
private final TLongLongHashMap counts = new TLongLongHashMap();
private final long interval;
public IntervalDateHistogramProc(long interval) {

View File

@ -1229,6 +1229,7 @@ public class SimpleFacetsTests extends AbstractNodesTests {
.addFacet(dateHistogramFacet("stats2").field("date").interval("day").zone("-02:00"))
.addFacet(dateHistogramFacet("stats3").field("date").valueField("num").interval("day").zone("-02:00"))
.addFacet(dateHistogramFacet("stats4").field("date").valueScript("doc['num'].value * 2").interval("day").zone("-02:00"))
.addFacet(dateHistogramFacet("stats5").field("date").interval("24h"))
.execute().actionGet();
if (searchResponse.failedShards() > 0) {
@ -1277,6 +1278,14 @@ public class SimpleFacetsTests extends AbstractNodesTests {
assertThat(facet.entries().get(1).time(), equalTo(timeInMillis("2009-03-05", DateTimeZone.forOffsetHours(-2))));
assertThat(facet.entries().get(1).count(), equalTo(2l));
assertThat(facet.entries().get(1).total(), equalTo(10d));
facet = searchResponse.facets().facet("stats5");
assertThat(facet.name(), equalTo("stats5"));
assertThat(facet.entries().size(), equalTo(2));
assertThat(facet.entries().get(0).time(), equalTo(utcTimeInMillis("2009-03-05")));
assertThat(facet.entries().get(0).count(), equalTo(2l));
assertThat(facet.entries().get(1).time(), equalTo(utcTimeInMillis("2009-03-06")));
assertThat(facet.entries().get(1).count(), equalTo(1l));
}
@Test public void testTermsStatsFacets() throws Exception {