Package org.elasticsearch.action.search

Examples of org.elasticsearch.action.search.SearchResponse.facets()


            SearchResponse searchResponse = client.prepareSearch()
                    .setQuery(matchAllQuery())
                    .addFacet(termsFacet("facet1").field("stag").size(10))
                    .execute().actionGet();

            TermsFacet facet = searchResponse.facets().facet("facet1");
            assertThat(facet.missingCount(), equalTo(1l));
        }
    }

    @Test public void testTermsFacetsNoHint() throws Exception {
View Full Code Here


                    .setQuery(termQuery("stag", "111"))
                    .addFacet(termsFacet("facet1").field("stag").size(10).executionHint(executionHint))
                    .addFacet(termsFacet("facet2").field("tag").size(10).executionHint(executionHint))
                    .execute().actionGet();

            TermsFacet facet = searchResponse.facets().facet("facet1");
            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.getTotalCount(), equalTo(2l));
            assertThat(facet.getOtherCount(), equalTo(0l));
            assertThat(facet.entries().size(), equalTo(1));
            assertThat(facet.entries().get(0).term(), equalTo("111"));
View Full Code Here

            assertThat(facet.getOtherCount(), equalTo(0l));
            assertThat(facet.entries().size(), equalTo(1));
            assertThat(facet.entries().get(0).term(), equalTo("111"));
            assertThat(facet.entries().get(0).count(), equalTo(2));

            facet = searchResponse.facets().facet("facet2");
            assertThat(facet.name(), equalTo("facet2"));
            assertThat(facet.entries().size(), equalTo(3));
            assertThat(facet.entries().get(0).term(), equalTo("yyy"));
            assertThat(facet.entries().get(0).count(), equalTo(2));
View Full Code Here

                    .addFacet(termsFacet("facet1").field("lstag").size(10).executionHint(executionHint))
                    .addFacet(termsFacet("facet2").field("ltag").size(10).executionHint(executionHint))
                    .addFacet(termsFacet("facet3").field("ltag").size(10).exclude(3000).executionHint(executionHint))
                    .execute().actionGet();

            facet = searchResponse.facets().facet("facet1");
            assertThat(facet, instanceOf(InternalLongTermsFacet.class));
            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.entries().size(), equalTo(1));
            assertThat(facet.entries().get(0).term(), equalTo("111"));
            assertThat(facet.entries().get(0).count(), equalTo(2));
View Full Code Here

            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.entries().size(), equalTo(1));
            assertThat(facet.entries().get(0).term(), equalTo("111"));
            assertThat(facet.entries().get(0).count(), equalTo(2));

            facet = searchResponse.facets().facet("facet2");
            assertThat(facet, instanceOf(InternalLongTermsFacet.class));
            assertThat(facet.name(), equalTo("facet2"));
            assertThat(facet.entries().size(), equalTo(3));
            assertThat(facet.entries().get(0).term(), equalTo("2000"));
            assertThat(facet.entries().get(0).count(), equalTo(2));
View Full Code Here

            assertThat(facet.entries().get(1).term(), anyOf(equalTo("1000"), equalTo("3000")));
            assertThat(facet.entries().get(1).count(), equalTo(1));
            assertThat(facet.entries().get(2).term(), anyOf(equalTo("1000"), equalTo("3000")));
            assertThat(facet.entries().get(2).count(), equalTo(1));

            facet = searchResponse.facets().facet("facet3");
            assertThat(facet, instanceOf(InternalLongTermsFacet.class));
            assertThat(facet.name(), equalTo("facet3"));
            assertThat(facet.entries().size(), equalTo(2));
            assertThat(facet.entries().get(0).term(), equalTo("2000"));
            assertThat(facet.entries().get(0).count(), equalTo(2));
View Full Code Here

                    .setQuery(termQuery("stag", "111"))
                    .addFacet(termsFacet("facet1").field("dstag").size(10).executionHint(executionHint))
                    .addFacet(termsFacet("facet2").field("dtag").size(10).executionHint(executionHint))
                    .execute().actionGet();

            facet = searchResponse.facets().facet("facet1");
            assertThat(facet, instanceOf(InternalDoubleTermsFacet.class));
            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.entries().size(), equalTo(1));
            assertThat(facet.entries().get(0).term(), equalTo("111.1"));
            assertThat(facet.entries().get(0).count(), equalTo(2));
View Full Code Here

            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.entries().size(), equalTo(1));
            assertThat(facet.entries().get(0).term(), equalTo("111.1"));
            assertThat(facet.entries().get(0).count(), equalTo(2));

            facet = searchResponse.facets().facet("facet2");
            assertThat(facet, instanceOf(InternalDoubleTermsFacet.class));
            assertThat(facet.name(), equalTo("facet2"));
            assertThat(facet.entries().size(), equalTo(3));
            assertThat(facet.entries().get(0).term(), equalTo("2000.1"));
            assertThat(facet.entries().get(0).count(), equalTo(2));
View Full Code Here

            searchResponse = client.prepareSearch()
                    .setQuery(termQuery("stag", "111"))
                    .addFacet(termsFacet("facet1").field("bstag").size(10).executionHint(executionHint))
                    .execute().actionGet();

            facet = searchResponse.facets().facet("facet1");
            assertThat(facet, instanceOf(InternalByteTermsFacet.class));
            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.entries().size(), equalTo(1));
            assertThat(facet.entries().get(0).term(), equalTo("111"));
            assertThat(facet.entries().get(0).count(), equalTo(2));
View Full Code Here

            searchResponse = client.prepareSearch()
                    .setQuery(termQuery("stag", "111"))
                    .addFacet(termsFacet("facet1").field("istag").size(10).executionHint(executionHint))
                    .execute().actionGet();

            facet = searchResponse.facets().facet("facet1");
            assertThat(facet, instanceOf(InternalIntTermsFacet.class));
            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.entries().size(), equalTo(1));
            assertThat(facet.entries().get(0).term(), equalTo("111"));
            assertThat(facet.entries().get(0).count(), equalTo(2));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.