Package org.elasticsearch.search.internal

Examples of org.elasticsearch.search.internal.InternalSearchResponse


        Set<String> idsLoaded = Sets.newHashSet();

        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));
        assertThat(result.queryResult().topDocs().totalHits, equalTo(5));

        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));

        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


            ExtTIntArrayList docIds = entry.getValue();
            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

            ExtTIntArrayList docIds = entry.getValue();
            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

                searchCache.releaseFetchResults(fetchResults);
            }
        }

        void innerFinishHim() throws Exception {
            final InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryResults, fetchResults);
            String scrollId = null;
            if (request.scroll() != null) {
                scrollId = TransportSearchHelper.buildScrollId(request.searchType(), dfsResults, null);
            }
            listener.onResponse(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildTookInMillis(), buildShardFailures()));
View Full Code Here

            queryFetchResults.put(result.shardTarget(), result);
        }

        @Override protected void moveToSecondPhase() throws Exception {
            // no need to sort, since we know we have no hits back
            final InternalSearchResponse internalResponse = searchPhaseController.merge(EMPTY_DOCS, queryFetchResults, ImmutableMap.<SearchShardTarget, FetchSearchResultProvider>of());
            String scrollId = null;
            if (request.scroll() != null) {
                scrollId = buildScrollId(request.searchType(), queryFetchResults.values(), null);
            }
            listener.onResponse(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildTookInMillis(), buildShardFailures()));
View Full Code Here

            }
        }

        void innerFinishHim() throws Exception {
            sortedShardList = searchPhaseController.sortDocs(queryFetchResults.values());
            final InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryFetchResults, queryFetchResults);
            String scrollId = null;
            if (request.scroll() != null) {
                scrollId = buildScrollId(request.searchType(), dfsResults, null);
            }
            listener.onResponse(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildTookInMillis(), buildShardFailures()));
View Full Code Here

            this.counter = new AtomicInteger(scrollId.context().length);
        }

        public void start() {
            if (scrollId.context().length == 0) {
                final InternalSearchResponse internalResponse = new InternalSearchResponse(new InternalSearchHits(InternalSearchHits.EMPTY, Long.parseLong(this.scrollId.attributes().get("total_hits")), 0.0f), null, false);
                searchCache.releaseQueryFetchResults(queryFetchResults);
                listener.onResponse(new SearchResponse(internalResponse, request.scrollId(), 0, 0, 0l, TransportSearchHelper.buildShardFailures(shardFailures, searchCache)));
                return;
            }
View Full Code Here

                ScoreDoc[] scoreDocs = shardResult.queryResult().topDocs().scoreDocs;
                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

            queryFetchResults.put(result.shardTarget(), result);
        }

        @Override protected void moveToSecondPhase() throws Exception {
            sortedShardList = searchPhaseController.sortDocs(queryFetchResults.values());
            final InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryFetchResults, queryFetchResults);
            String scrollId = null;
            if (request.scroll() != null) {
                scrollId = buildScrollId(request.searchType(), queryFetchResults.values(), null);
            }
            listener.onResponse(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildTookInMillis(), buildShardFailures()));
View Full Code Here

                searchCache.releaseFetchResults(fetchResults);
            }
        }

        void innerFinishHim() throws Exception {
            InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryResults, fetchResults);
            String scrollId = null;
            if (request.scroll() != null) {
                scrollId = TransportSearchHelper.buildScrollId(request.searchType(), queryResults.values(), null);
            }
            listener.onResponse(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildTookInMillis(), buildShardFailures()));
View Full Code Here

TOP

Related Classes of org.elasticsearch.search.internal.InternalSearchResponse

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.