Package org.elasticsearch.action.search

Examples of org.elasticsearch.action.search.SearchResponse.scrollId()


                assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++));
            }
        }

        // and now, the last one is one
        searchResponse = client.prepareSearchScroll(searchResponse.scrollId())
                .setScroll(TimeValue.timeValueMinutes(2))
                .execute().actionGet();

        assertThat(searchResponse.hits().getTotalHits(), equalTo(100l));
        assertThat(searchResponse.hits().hits().length, equalTo(1));
View Full Code Here


        for (SearchHit hit : searchResponse.hits()) {
            assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++));
        }

        // a the last is zero
        searchResponse = client.prepareSearchScroll(searchResponse.scrollId())
                .setScroll(TimeValue.timeValueMinutes(2))
                .execute().actionGet();

        assertThat(searchResponse.hits().getTotalHits(), equalTo(100l));
        assertThat(searchResponse.hits().hits().length, equalTo(0));
View Full Code Here

            for (SearchHit searchHit : searchResponse.hits().hits()) {
                Map<String, Object> map = searchHit.sourceAsMap();
                map.put("message", "update");
                client.prepareIndex("test", "tweet", searchHit.id()).setSource(map).execute().actionGet();
            }
            searchResponse = client.prepareSearchScroll(searchResponse.scrollId()).setScroll(TimeValue.timeValueMinutes(2)).execute().actionGet();
        } while (searchResponse.hits().hits().length > 0);

        client.admin().indices().prepareRefresh().execute().actionGet();
        assertThat(client.prepareCount().setQuery(matchAllQuery()).execute().actionGet().count(), equalTo(500l));
        assertThat(client.prepareCount().setQuery(termQuery("message", "test")).execute().actionGet().count(), equalTo(0l));
View Full Code Here

        assertThat(searchResponse.hits().totalHits(), equalTo(numberOfDocs));

        // start scrolling, until we get not results
        while (true) {
            searchResponse = client.prepareSearchScroll(searchResponse.scrollId()).setScroll(TimeValue.timeValueMinutes(2)).execute().actionGet();
            assertThat(searchResponse.hits().totalHits(), equalTo(numberOfDocs));
            assertThat(searchResponse.failedShards(), equalTo(0));
            for (SearchHit hit : searchResponse.hits()) {
                assertThat(hit.id() + "should not exists in the result set", ids.contains(hit.id()), equalTo(false));
                ids.add(hit.id());
View Full Code Here

        assertThat(searchResponse.hits().totalHits(), equalTo(100l));

        // start scrolling, until we get not results
        while (true) {
            searchResponse = client.prepareSearchScroll(searchResponse.scrollId()).setScroll(TimeValue.timeValueMinutes(2)).execute().actionGet();
            assertThat(searchResponse.hits().totalHits(), equalTo(100l));
            assertThat(searchResponse.failedShards(), equalTo(0));
            for (SearchHit hit : searchResponse.hits()) {
                assertThat(hit.id() + "should not exists in the result set", ids.contains(hit.id()), equalTo(false));
                ids.add(hit.id());
View Full Code Here

        SearchResponse rsp = srb.execute().actionGet();

        try {
            int counter = 0;
            while (true) {
                rsp = client.prepareSearchScroll(rsp.scrollId()).
                        setScroll(TimeValue.timeValueMinutes(keepTimeInMinutes)).execute().actionGet();
                long currentResults = rsp.hits().hits().length;
                logger.info("(" + counter++ + ") scanquery with " + pageSize + " page size and " + currentResults + " hits");
                if (currentResults == 0)
                    break;
View Full Code Here

            try {
                long total = rsp.hits().totalHits();
                int collectedResults = 0;
                while (true) {
                    StopWatch queryWatch = new StopWatch().start();
                    rsp = client.prepareSearchScroll(rsp.scrollId()).
                            setScroll(TimeValue.timeValueMinutes(keepTime)).execute().actionGet();
                    long currentResults = rsp.hits().hits().length;
                    if (currentResults == 0)
                        break;
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.