Package org.elasticsearch.search

Examples of org.elasticsearch.search.SearchHits.hits()


        queryFetchResults = scrollQueryFetchResults;

        sortedShardList = searchPhaseController.sortDocs(queryFetchResults.values());
        hits = searchPhaseController.merge(sortedShardList, queryFetchResults, queryFetchResults).hits();
        assertThat(hits.totalHits(), equalTo(100l));
        assertThat(hits.hits().length, equalTo(40));
        for (int i = 0; i < 40; i++) {
            SearchHit hit = hits.hits()[i];
//            System.out.println(hit.id() + " " + hit.explanation());
            // we don't do perfect sorting when it comes to scroll with Query+Fetch
//            assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - 60 - 1 - i)));
View Full Code Here


        sortedShardList = searchPhaseController.sortDocs(queryFetchResults.values());
        hits = searchPhaseController.merge(sortedShardList, queryFetchResults, queryFetchResults).hits();
        assertThat(hits.totalHits(), equalTo(100l));
        assertThat(hits.hits().length, equalTo(40));
        for (int i = 0; i < 40; i++) {
            SearchHit hit = hits.hits()[i];
//            System.out.println(hit.id() + " " + hit.explanation());
            // we don't do perfect sorting when it comes to scroll with Query+Fetch
//            assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - 60 - 1 - i)));
            assertThat("make sure we don't have duplicates", expectedIds.remove(hit.id()), notNullValue());
        }
View Full Code Here

        }

        SearchHits hits = searchPhaseController.merge(sortedShardList, queryResults, fetchResults).hits();

        assertThat(hits.totalHits(), equalTo(100l));
        assertThat(hits.hits().length, equalTo(60));
        for (int i = 0; i < 60; i++) {
            SearchHit hit = hits.hits()[i];
//            System.out.println(hit.explanation());
            assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - i - 1)));
        }
View Full Code Here

        SearchHits hits = searchPhaseController.merge(sortedShardList, queryResults, fetchResults).hits();

        assertThat(hits.totalHits(), equalTo(100l));
        assertThat(hits.hits().length, equalTo(60));
        for (int i = 0; i < 60; i++) {
            SearchHit hit = hits.hits()[i];
//            System.out.println(hit.explanation());
            assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - i - 1)));
        }

        // now try and scroll to the next batch of results
View Full Code Here

            fetchResults.put(fetchResult.shardTarget(), fetchResult.initCounter());
        }

        hits = searchPhaseController.merge(sortedShardList, queryResults, fetchResults).hits();
        assertThat(hits.totalHits(), equalTo(100l));
        assertThat(hits.hits().length, equalTo(40));
        for (int i = 0; i < 40; i++) {
            SearchHit hit = hits.hits()[i];
            assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - 60 - 1 - i)));
        }
    }
View Full Code Here

        hits = searchPhaseController.merge(sortedShardList, queryResults, fetchResults).hits();
        assertThat(hits.totalHits(), equalTo(100l));
        assertThat(hits.hits().length, equalTo(40));
        for (int i = 0; i < 40; i++) {
            SearchHit hit = hits.hits()[i];
            assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - 60 - 1 - i)));
        }
    }

    @Test public void testDfsQueryThenFetchWithSort() throws Exception {
View Full Code Here

                        .converter(new EsTimestampConverter(), timestampFields)
                        .excludesWhitespace().execute();
                callback.iterate(accessResult);
            }

            if (searchHits.hits().length == 0) {
                break;
            }
            response = riverConfig.getClient()
                    .prepareSearchScroll(response.getScrollId())
                    .setScroll(new TimeValue(scrollTimeout)).execute()
View Full Code Here

        return new MySearchHits() {
            @Override public Iterable<MySearchHit> getHits() {
                return new Iterable<MySearchHit>() {
                    @Override public Iterator<MySearchHit> iterator() {
                        return new Iterator<MySearchHit>() {
                            SearchHit[] arr = hits.hits();
                            int counter = 0;

                            @Override public boolean hasNext() {
                                return counter < arr.length;
                            }
View Full Code Here

    }
   
    @Override
    public List<T> collectObjects(SearchResponse rsp) {
        SearchHits docs = rsp.getHits();
        List<T> list = new ArrayList<T>(docs.hits().length);
        for (SearchHit sd : docs) {
            if (sd.getExplanation() != null) {
                String res = "";
                for (Explanation str : sd.getExplanation().getDetails()) {
                    res += str.toString();
View Full Code Here

        twSearch.testUpdate(createTweet(1L, "text", "peter"));
        SearchHits h = twSearch.query(new TweetQuery()).hits();
        assertEquals(1, h.totalHits());

        Collection<Integer> res = twSearch.bulkUpdate(
                Arrays.asList(createTweet(1L, "text", "peter").setRetweetCount(1).setVersion(h.hits()[0].getVersion())),
                twSearch.getIndexName());
        assertEquals(0, res.size());
        twSearch.refresh();

        assertEquals(1, twSearch.searchTweets(new TweetQuery()).size());
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.