# Java with twitter4j and send info to elasticsearch

**URL:** <https://discuss.elastic.co/t/java-with-twitter4j-and-send-info-to-elasticsearch/92541>\
**Category:** Elasticsearch\
**Created:** [July 10, 2017, 10:10pm UTC](https://discuss.elastic.co/t/java-with-twitter4j-and-send-info-to-elasticsearch/92541 "2017-07-10T22:10:54Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![Lbr1](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@Lbr1](https://discuss.elastic.co/u/Lbr1)\
**Post date:** [August 15, 2017, 4:05pm UTC](https://discuss.elastic.co/t/java-with-twitter4j-and-send-info-to-elasticsearch/92541/21 "2017-08-15T16:05:35Z")

</div>

Thanks for the answer.  
I have managed to solve my previous problems and I am now trying to implement the scroll in java.

I have read what it consists of, it works as a "pointer" to the next range of values.

But I'm having a problem, the same I had when trying to delete documents from an index, which is the client.

I'm using the rest API and created a restClient,

```
RestClient restClient = RestClient.builder(
				new HttpHost("localhost", 9200, "http"),
				new HttpHost("localhost", 9201, "http")).build();

```

but in many codes a **Client** is used. As in the following example, how do I get this client from the restClient? Or are they different things?

Example:

```
import static org.elasticsearch.index.query.QueryBuilders.*;

QueryBuilder qb = termQuery("multi", "test");

SearchResponse scrollResp = client.prepareSearch(test)
        .addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC)
        .setScroll(new TimeValue(60000))
        .setQuery(qb)
        .setSize(100).get(); //max of 100 hits will be returned for each scroll
//Scroll until no hits are returned
do {
    for (SearchHit hit : scrollResp.getHits().getHits()) {
        //Handle the hit...
    }

    scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(60000)).execute().actionGet();
} while(scrollResp.getHits().getHits().length != 0); // Zero hits mark the end of the scroll and the while loop.

```

thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 12, 2017, 4:05pm UTC](https://discuss.elastic.co/t/java-with-twitter4j-and-send-info-to-elasticsearch/92541/22 "2017-09-12T16:05:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

[Previous page](https://discuss.elastic.co/t/java-with-twitter4j-and-send-info-to-elasticsearch/92541.md?page=1)
