Package crate.elasticsearch.facet.distinct

Examples of crate.elasticsearch.facet.distinct.InternalDistinctDateHistogramFacet


                .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}" +
View Full Code Here


                .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("long_type", 2)
                        .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("long_type")
                        .value(2)
                        .value(3)
                        .endArray()
                        .endObject())
                .execute().actionGet();
        client.prepareIndex("distinct_data_1", "data", "4")
                .setSource(XContentFactory.jsonBuilder()
                        .startObject()
                        .field("created_at", 2000000000)
                        .startArray("long_type")
                        .value(3)
                        .value(4)
                        .endArray()
                        .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}" +
View Full Code Here

TOP

Related Classes of crate.elasticsearch.facet.distinct.InternalDistinctDateHistogramFacet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.