Package org.elasticsearch.action.search

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


            searchResponse = client.prepareSearch()
                    .setQuery(matchAllQuery())
                    .addFacet(termsFacet("facet1").field("tag").size(10).script("term == 'xxx' ? false : true").order(TermsFacet.ComparatorType.TERM).executionHint(executionHint))
                    .execute().actionGet();

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


            searchResponse = client.prepareSearch()
                    .setQuery(matchAllQuery())
                    .addFacet(termsFacet("facet1").fields("stag", "tag").size(10).executionHint(executionHint))
                    .execute().actionGet();

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

            searchResponse = client.prepareSearch()
                    .setQuery(termQuery("xxx", "yyy")) // don't match anything
                    .addFacet(termsFacet("facet1").field("tag").size(10).allTerms(true).executionHint(executionHint))
                    .execute().actionGet();

            facet = searchResponse.facets().facet("facet1");
            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.entries().size(), equalTo(3));
            assertThat(facet.entries().get(0).term(), anyOf(equalTo("xxx"), equalTo("yyy"), equalTo("zzz")));
            assertThat(facet.entries().get(0).count(), equalTo(0));
            assertThat(facet.entries().get(1).term(), anyOf(equalTo("xxx"), equalTo("yyy"), equalTo("zzz")));
View Full Code Here

                    .setQuery(matchAllQuery())
                    .addFacet(termsFacet("facet1").scriptField("_source.stag").size(10).executionHint(executionHint))
                    .addFacet(termsFacet("facet2").scriptField("_source.tag").size(10).executionHint(executionHint))
                    .execute().actionGet();

            facet = searchResponse.facets().facet("facet1");
            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.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

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

            TermsFacet facet = searchResponse.facets().facet("facet1");
            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.entries().size(), equalTo(3));
            for (int j = 0; j < 3; j++) {
                assertThat(facet.entries().get(j).term(), anyOf(equalTo("foo"), equalTo("bar"), equalTo("baz")));
                assertThat(facet.entries().get(j).count(), equalTo(10));
View Full Code Here

                    logger.warn("-> {}", shardSearchFailure);
                }
            }
            assertThat(searchResponse.failedShards(), equalTo(0));

            StatisticalFacet facet = searchResponse.facets().facet("stats1");
            assertThat(facet.name(), equalTo(facet.name()));
            assertThat(facet.count(), equalTo(2l));
            assertThat(facet.total(), equalTo(3d));
            assertThat(facet.min(), equalTo(1d));
            assertThat(facet.max(), equalTo(2d));
View Full Code Here

            assertThat(facet.min(), equalTo(1d));
            assertThat(facet.max(), equalTo(2d));
            assertThat(facet.mean(), equalTo(1.5d));
            assertThat(facet.sumOfSquares(), equalTo(5d));

            facet = searchResponse.facets().facet("stats2");
            assertThat(facet.name(), equalTo(facet.name()));
            assertThat(facet.count(), equalTo(4l));
            assertThat(facet.total(), equalTo(10d));
            assertThat(facet.min(), equalTo(1d));
            assertThat(facet.max(), equalTo(4d));
View Full Code Here

            assertThat(facet.total(), equalTo(10d));
            assertThat(facet.min(), equalTo(1d));
            assertThat(facet.max(), equalTo(4d));
            assertThat(facet.mean(), equalTo(2.5d));

            facet = searchResponse.facets().facet("stats3");
            assertThat(facet.name(), equalTo(facet.name()));
            assertThat(facet.count(), equalTo(2l));
            assertThat(facet.total(), equalTo(6d));
            assertThat(facet.min(), equalTo(2d));
            assertThat(facet.max(), equalTo(4d));
View Full Code Here

                    .setQuery(matchAllQuery())
                    .addFacet(statisticalFacet("stats").fields("num", "multi_num"))
                    .execute().actionGet();


            facet = searchResponse.facets().facet("stats");
            assertThat(facet.name(), equalTo(facet.name()));
            assertThat(facet.count(), equalTo(6l));
            assertThat(facet.total(), equalTo(13d));
            assertThat(facet.min(), equalTo(1d));
            assertThat(facet.max(), equalTo(4d));
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.