client().admin().indices().prepareRefresh().execute().actionGet();
final SearchResponse searchResponse = client()
.prepareSearch()
.setQuery(matchAllQuery())
.addFacet(new DateFacetBuilder("stats1").keyField("date").distinctField("num").interval("day").mode(mode))
.addFacet(new DateFacetBuilder("stats2").keyField("date").distinctField("num").interval("day").preZone("-02:00").mode(mode))
.addFacet(new DateFacetBuilder("stats3").keyField("date").distinctField("num").interval("day").preZone("-02:00").mode(mode))
// .addFacet(
// new DateFacetBuilder("stats4").keyField("date").distinctScript("doc['num'].distinct * 2").interval("day").preZone("-02:00")
// .mode(mode))
.addFacet(new DateFacetBuilder("stats5").keyField("date").distinctField("num").interval("24h").mode(mode))
.addFacet(
new DateFacetBuilder("stats6").keyField("date").distinctField("num").interval("day").preZone("-02:00").postZone("-02:00")
.mode(mode))
.addFacet(new DateFacetBuilder("stats7").keyField("date").distinctField("num").interval("quarter").mode(mode))
.execute().actionGet();
if(searchResponse.getFailedShards() > 0) {
System.out.println(searchResponse);
fail(Joiner.on(", ").join(searchResponse.getShardFailures()));