Package org.elasticsearch.search.facet

Examples of org.elasticsearch.search.facet.InternalFacets


                }
            }
        }

        // merge facets
        InternalFacets facets = null;
        if (!queryResults.isEmpty()) {
            // we rely on the fact that the order of facets is the same on all query results
            if (querySearchResult.facets() != null && querySearchResult.facets().facets() != null && !querySearchResult.facets().facets().isEmpty()) {
                List<Facet> aggregatedFacets = Lists.newArrayList();
                List<Facet> namedFacets = Lists.newArrayList();
                for (Facet facet : querySearchResult.facets()) {
                    // aggregate each facet name into a single list, and aggregate it
                    namedFacets.clear();
                    for (QuerySearchResultProvider queryResultProvider : queryResults.values()) {
                        for (Facet facet1 : queryResultProvider.queryResult().facets()) {
                            if (facet.name().equals(facet1.name())) {
                                namedFacets.add(facet1);
                            }
                        }
                    }
                    Facet aggregatedFacet = facetProcessors.processor(facet.type()).reduce(facet.name(), namedFacets);
                    aggregatedFacets.add(aggregatedFacet);
                }
                facets = new InternalFacets(aggregatedFacets);
            }
        }

        // count the total (we use the query result provider here, since we might not get any hits (we scrolled past them))
        long totalHits = 0;
View Full Code Here


                ElasticTweetSearch twSearch = mock(ElasticTweetSearch.class);

                // mock this hit/result too!
                //new InternalSearchHit(1, "1", "tweet", source, fields);
                InternalSearchResponse iRsp2 = new InternalSearchResponse(
                        new InternalSearchHits(new InternalSearchHit[0], 0, 0), new InternalFacets(new ArrayList()), true);
                when(twSearch.query((Collection<JUser>) any(), (TweetQuery) any())).
                        thenReturn(new SearchResponse(iRsp2, "", 4, 4, 1L, new ShardSearchFailure[0]));

                bind(ElasticTweetSearch.class).toInstance(twSearch);
            }
View Full Code Here

            // anyway. Alternatively, we could serialize/ filter/ deserialize JSON, but this seems simpler.
            SearchHits allHits  = response.getHits();
            InternalSearchHit [] trimmedHits = new InternalSearchHit[Math.min(maxHits, allHits.hits().length)];
            System.arraycopy(allHits.hits(), 0, trimmedHits, 0, trimmedHits.length);

            InternalFacets facets = null;
            if (response.getFacets() != null) {
                facets = new InternalFacets(response.getFacets().facets());
            }

            InternalAggregations aggregations = null;
            if (response.getAggregations() != null) {
                aggregations = new InternalAggregations(toInternal(response.getAggregations().asList()));
View Full Code Here

TOP

Related Classes of org.elasticsearch.search.facet.InternalFacets

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.