.endObject();
SearchResponse response = client.prepareSearch()
.setSearchType(SearchType.COUNT)
.setFacets(facetQuery.bytes().array())
.execute().actionGet();
InternalDistinctDateHistogramFacet facet = (InternalDistinctDateHistogramFacet) response.getFacets().facet("distinct");
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).startObject();
facet.toXContent(builder, ToXContent.EMPTY_PARAMS).endObject();
assertThat(builder.string(), equalTo(
"{\"distinct\":{" +
"\"_type\":\"distinct_date_histogram\",\"entries\":[" +
"{\"time\":950400000,\"count\":1}" +
"]," +
"\"count\":1" +
"}" +
"}"));
client.prepareIndex("distinct_data_1", "data", "2")
.setSource(XContentFactory.jsonBuilder()
.startObject()
.field("created_at", 1000000000)
.field("distinct", "2")
.field("wrong_type", 1.1)
.endObject())
.execute().actionGet();
flush();
response = client.prepareSearch()
.setSearchType(SearchType.COUNT)
.setFacets(facetQuery.bytes().array())
.execute().actionGet();
facet = (InternalDistinctDateHistogramFacet) response.getFacets().facet("distinct");
builder = XContentFactory.contentBuilder(XContentType.JSON).startObject();
facet.toXContent(builder, ToXContent.EMPTY_PARAMS).endObject();
assertThat(builder.string(), equalTo(
"{\"distinct\":{" +
"\"_type\":\"distinct_date_histogram\",\"entries\":[" +
"{\"time\":950400000,\"count\":2}" +
"]," +
"\"count\":2" +
"}" +
"}"));
client.prepareIndex("distinct_data_1", "data", "3")
.setSource(XContentFactory.jsonBuilder()
.startObject()
.field("created_at", 2000000000)
.startArray("distinct")
.value("2")
.value("3")
.endArray()
.field("wrong_type", 1.1)
.endObject())
.execute().actionGet();
client.prepareIndex("distinct_data_1", "data", "4")
.setSource(XContentFactory.jsonBuilder()
.startObject()
.field("created_at", 2000000000)
.startArray("distinct")
.value("3")
.value("4")
.endArray()
.field("wrong_type", 1.1)
.endObject())
.execute().actionGet();
flush();
response = client.prepareSearch()
.setSearchType(SearchType.COUNT)
.setFacets(facetQuery.bytes().array())
.execute().actionGet();
facet = (InternalDistinctDateHistogramFacet) response.getFacets().facet("distinct");
builder = XContentFactory.contentBuilder(XContentType.JSON).startObject();
facet.toXContent(builder, ToXContent.EMPTY_PARAMS).endObject();
assertThat(builder.string(), equalTo(
"{\"distinct\":{" +
"\"_type\":\"distinct_date_histogram\",\"entries\":[" +
"{\"time\":950400000,\"count\":2}," +
"{\"time\":1555200000,\"count\":3}" +