Package org.elasticsearch.action.search

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


                    .addFacet(statisticalFacet("stats").field("num"))
                    .addFacet(statisticalFacet("stats").field("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


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

            HistogramFacet facet = searchResponse.facets().facet("facet1");
            assertThat(facet.name(), equalTo("facet1"));
            assertThat(facet.entries().size(), equalTo(3));
            assertThat(facet.entries().get(0).key(), equalTo(100l));
            assertThat(facet.entries().get(0).count(), equalTo(1l));
            assertThat(facet.entries().get(1).key(), equalTo(200l));
View Full Code Here

        SearchResponse searchResponse = client.search(searchRequest("test").source(sourceBuilder)).actionGet();
        assertThat("Failures " + Arrays.toString(searchResponse.shardFailures()), searchResponse.shardFailures().length, equalTo(0));
        assertThat(searchResponse.hits().totalHits(), equalTo(100l));

        assertThat(searchResponse.facets().facet(QueryFacet.class, "test1").count(), equalTo(1l));
        assertThat(searchResponse.facets().facet(QueryFacet.class, "all").count(), equalTo(100l));
    }

    @Test public void testSimpleFacetsTwice() throws Exception {
        testSimpleFacets();
View Full Code Here

        SearchResponse searchResponse = client.search(searchRequest("test").source(sourceBuilder)).actionGet();
        assertThat("Failures " + Arrays.toString(searchResponse.shardFailures()), searchResponse.shardFailures().length, equalTo(0));
        assertThat(searchResponse.hits().totalHits(), equalTo(100l));

        assertThat(searchResponse.facets().facet(QueryFacet.class, "test1").count(), equalTo(1l));
        assertThat(searchResponse.facets().facet(QueryFacet.class, "all").count(), equalTo(100l));
    }

    @Test public void testSimpleFacetsTwice() throws Exception {
        testSimpleFacets();
        testSimpleFacets();
View Full Code Here

                createTweet(3L, "third tweet", "userA")));

        SearchResponse rsp = twSearch.query(new TweetQuery(true));
        assertEquals(3, rsp.hits().getTotalHits());
        // only the second tweet will contain a tag with atom!
        assertEquals(1, ((TermsFacet) rsp.facets().facet("tag")).getEntries().size());

        rsp = twSearch.query(new TweetQuery().addFilterQuery("tag", "atom"));
        assertEquals(2, twSearch.collectObjects(rsp).size());
    }
View Full Code Here

        SearchHits sh = mock(SearchHits.class);
        when(sh.getTotalHits()).thenReturn(10L);

        SearchResponse sr = mock(SearchResponse.class);
        when(sr.hits()).thenReturn(sh);
        when(sr.facets()).thenReturn(new Facets() {

            @Override
            public List<Facet> facets() {
                throw new UnsupportedOperationException("Not supported yet.");
            }
View Full Code Here

    @Test
    public void testUpdateFacetLinks() {
        FacetPanel panel = (FacetPanel) tester.startPanel(FacetPanel.class);              
        SearchResponse sr = mock(SearchResponse.class);               
        when(sr.facets()).thenReturn(new Facets() {

            @Override
            public List<Facet> facets() {
                Set<InternalStringTermsFacet.StringEntry> entries = new LinkedHashSet();
                entries.add(new InternalStringTermsFacet.StringEntry("de", 3));
View Full Code Here

                tfb.regex(secPart + ".*", Pattern.DOTALL);

            srb.addFacet(tfb);
            SearchResponse rsp = query(new ArrayList<JUser>(), srb.execute().actionGet());
            Set<String> res = new TreeSet<String>();
            TermsFacet tf = rsp.facets().facet(TAG);
            if (tf != null) {
                for (TermsFacet.Entry cnt : tf.entries()) {
                    String lowerSugg = cnt.getTerm().toLowerCase();
                    if (existingTerms.contains(lowerSugg))
                        continue;
View Full Code Here

    public Collection<String> searchTrends(JetwickQuery q, int limit) {
        try {
            q.addFacetField(TAG);
            SearchResponse rsp = query(q);
            Facets facets = rsp.facets();
            if (facets == null)
                return Collections.emptyList();

            Set<String> set = new LinkedHashSet<String>();
            for (Facet facet : facets.facets()) {
View Full Code Here

        List<Entry<String, Long>> list = new ArrayList<Entry<String, Long>>();
        int counter = 0;
        boolean forceDateSuggestion = false;
        for (Entry<String, Object> e : q.getFilterQueries()) {
            QueryFacet qf = (QueryFacet) rsp.facets().facet("ss_" + counter);
            list.add(new MapEntry<String, Long>(e.getKey(), qf.count()));
            counter++;
            if (DATE.equals(e.getKey())) {
                try {
                    String str = (String) e.getValue();
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.