Package org.elasticsearch.search.internal

Examples of org.elasticsearch.search.internal.InternalSearchResponse.hits()


        ShardDoc[] sortedShardList = searchPhaseController.sortDocs(newArrayList(result));
        Map<SearchShardTarget, QueryFetchSearchResult> queryResults = Maps.newHashMap();
        queryResults.put(result.queryResult().shardTarget(), result);
        InternalSearchResponse searchResponse = searchPhaseController.merge(sortedShardList, queryResults, queryResults);

        for (SearchHit hit : searchResponse.hits()) {
            idsLoaded.add(hit.id());
        }

        // iterate to the next 2
        result = searchService.executeFetchPhase(searchRequest(searchSource().query(matchAllQuery()).from(2).size(2).sort("age", SortOrder.DESC), SearchType.QUERY_AND_FETCH));
View Full Code Here


        sortedShardList = searchPhaseController.sortDocs(newArrayList(result));
        queryResults = Maps.newHashMap();
        queryResults.put(result.queryResult().shardTarget(), result);
        searchResponse = searchPhaseController.merge(sortedShardList, queryResults, queryResults);

        for (SearchHit hit : searchResponse.hits()) {
            idsLoaded.add(hit.id());
        }
        result = searchService.executeFetchPhase(searchRequest(searchSource().query(matchAllQuery()).from(4).size(2).sort("age", SortOrder.DESC), SearchType.QUERY_AND_FETCH));
        assertThat(result.queryResult().topDocs().totalHits, equalTo(5));
View Full Code Here

        sortedShardList = searchPhaseController.sortDocs(newArrayList(result));
        queryResults = Maps.newHashMap();
        queryResults.put(result.queryResult().shardTarget(), result);
        searchResponse = searchPhaseController.merge(sortedShardList, queryResults, queryResults);

        for (SearchHit hit : searchResponse.hits()) {
            idsLoaded.add(hit.id());
        }

        // verify all ids were loaded
        Set<String> expectedIds = Sets.newHashSet("1", "2", "3", "4", "5");
View Full Code Here

            FetchSearchResult fetchResult = nodeToSearchService.get(shardTarget.nodeId()).executeFetchPhase(new FetchSearchRequest(queryResults.get(shardTarget).queryResult().id(), docIds));
            fetchResults.put(fetchResult.shardTarget(), fetchResult.initCounter());
        }

        InternalSearchResponse searchResponse = searchPhaseController.merge(sortedShardList, queryResults, fetchResults);
        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));
    }
View Full Code Here

            FetchSearchResult fetchResult = nodeToSearchService.get(shardTarget.nodeId()).executeFetchPhase(new FetchSearchRequest(queryResults.get(shardTarget).queryResult().id(), docIds));
            fetchResults.put(fetchResult.shardTarget(), fetchResult.initCounter());
        }

        InternalSearchResponse searchResponse = searchPhaseController.merge(sortedShardList, queryResults, fetchResults);
        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));
    }
View Full Code Here

                for (ScoreDoc scoreDoc : scoreDocs) {
                    docs[counter++] = new ShardScoreDoc(shardResult.shardTarget(), scoreDoc.doc, 0.0f);
                }
            }
            final InternalSearchResponse internalResponse = searchPhaseController.merge(docs, queryFetchResults, queryFetchResults);
            ((InternalSearchHits) internalResponse.hits()).totalHits = Long.parseLong(this.scrollId.attributes().get("total_hits"));


            for (QueryFetchSearchResult shardResult : queryFetchResults.values()) {
                if (shardResult.queryResult().topDocs().scoreDocs.length < shardResult.queryResult().size()) {
                    // we found more than we want for this round, remove this from our scrolling
View Full Code Here

        @Override protected void moveToSecondPhase() throws Exception {
            final InternalSearchResponse internalResponse = searchPhaseController.merge(EMPTY_DOCS, queryResults, ImmutableMap.<SearchShardTarget, FetchSearchResultProvider>of());
            String scrollId = null;
            if (request.scroll() != null) {
                scrollId = buildScrollId(request.searchType(), queryResults.values(), ImmutableMap.of("total_hits", Long.toString(internalResponse.hits().totalHits())));
            }
            listener.onResponse(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildTookInMillis(), buildShardFailures()));
            searchCache.releaseQueryResults(queryResults);
        }
    }
View Full Code Here

                                    new ShardSearchFailure[shardFailures.length()]));
                            result.setException(ex);
                            return;
                        }
                        InternalSearchResponse response = searchPhaseController.merge(sortedShardList, firstResults, fetchResults);
                        final SearchHit[] hits = response.hits().hits();
                        final Object[][] rows = new Object[hits.length][numColumns];

                        for (int r = 0; r < hits.length; r++) {
                            rows[r] = new Object[numColumns];
                            for (int c = 0; c < numColumns; c++) {
View Full Code Here

        @Override
        protected void moveToSecondPhase() throws Exception {
            final InternalSearchResponse internalResponse = searchPhaseController.merge(SearchPhaseController.EMPTY_DOCS, firstResults, (AtomicArray<? extends FetchSearchResultProvider>) AtomicArray.empty());
            String scrollId = null;
            if (request.scroll() != null) {
                scrollId = buildScrollId(request.searchType(), firstResults, ImmutableMap.of("total_hits", Long.toString(internalResponse.hits().totalHits())));
            }
            listener.onResponse(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successfulOps.get(), buildTookInMillis(), buildShardFailures()));
        }
    }
}
View Full Code Here

                    scoreDoc.shardIndex = entry.index;
                    docs[counter++] = scoreDoc;
                }
            }
            final InternalSearchResponse internalResponse = searchPhaseController.merge(docs, queryFetchResults, queryFetchResults);
            ((InternalSearchHits) internalResponse.hits()).totalHits = Long.parseLong(this.scrollId.getAttributes().get("total_hits"));


            for (AtomicArray.Entry<QueryFetchSearchResult> entry : queryFetchResults.asList()) {
                if (entry.value.queryResult().topDocs().scoreDocs.length < entry.value.queryResult().size()) {
                    // we found more than we want for this round, remove this from our scrolling
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.