Package org.elasticsearch.search.fetch

Examples of org.elasticsearch.search.fetch.QueryFetchSearchResult.queryResult()


        assertThat(queryResult.topDocs().totalHits, equalTo(1));
    }

    @Test public void testDirectFetch() throws Exception {
        QueryFetchSearchResult queryFetchResult = searchService.executeFetchPhase(searchRequest(searchSource().query(termQuery("name", "test1")), SearchType.QUERY_AND_FETCH));
        assertThat(queryFetchResult.queryResult().topDocs().totalHits, equalTo(1));
        assertThat(queryFetchResult.fetchResult().hits().hits().length, equalTo(1));
        assertThat(queryFetchResult.fetchResult().hits().hits()[0].sourceAsString(), equalTo(source("1", "test1", 1)));
        assertThat(queryFetchResult.fetchResult().hits().hits()[0].id(), equalTo("1"));
        assertThat(queryFetchResult.fetchResult().hits().hits()[0].type(), equalTo("type1"));
    }
View Full Code Here


        assertThat(fetchResult.hits().hits()[0].type(), equalTo("type1"));
    }

    @Test public void testQueryAndFetchIterateWithFrom() throws Exception {
        QueryFetchSearchResult result = searchService.executeFetchPhase(searchRequest(searchSource().query(matchAllQuery()).from(0).size(2).sort("age", SortOrder.DESC), SearchType.QUERY_AND_FETCH));
        assertThat(result.queryResult().topDocs().totalHits, equalTo(5));

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

        ShardDoc[] sortedShardList = searchPhaseController.sortDocs(newArrayList(result));
        Map<SearchShardTarget, QueryFetchSearchResult> queryResults = Maps.newHashMap();
View Full Code Here

        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());
        }
View Full Code Here

            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);
View Full Code Here

        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());
        }
View Full Code Here

        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);
View Full Code Here

        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());
        }
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.