# How to do scan and scroll using Elastic4s

**URL:** https://discuss.elastic.co/t/how-to-do-scan-and-scroll-using-elastic4s/25458
**Category:** Elasticsearch
**Created:** [July 13, 2015, 3:58pm UTC](https://discuss.elastic.co/t/how-to-do-scan-and-scroll-using-elastic4s/25458 "2015-07-13T15:58:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ningjun](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@Ningjun](https://discuss.elastic.co/u/Ningjun)
#### Post date: [July 13, 2015, 3:58pm UTC](https://discuss.elastic.co/t/how-to-do-scan-and-scroll-using-elastic4s/25458/1 "2015-07-13T15:58:39Z")

</div>

I am using Elastic4s (SCALA client for elastic search). I need to retrieve all 10 millions documents in an index. I think the right way to do is using scan and scroll.

Is there any code snippet or examples showing how to do scan and scroll using Elastic4s?

---

<div class="post-metadata">

### Author: ![sksamuel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sksamuel/32/682_2.png) [@sksamuel](https://discuss.elastic.co/u/sksamuel)
#### Post date: [July 28, 2015, 8:40pm UTC](https://discuss.elastic.co/t/how-to-do-scan-and-scroll-using-elastic4s/25458/2 "2015-07-28T20:40:10Z")

</div>

```
client.execute {
   search in "index" / "type" query <yourquery> scroll "1m"
}

```

then

```
client.execute {
   search scroll <id>
}

```

This example should help:  
[https://github.com/sksamuel/elastic4s/blob/master/elastic4s-core%2Fsrc%2Ftest%2Fscala%2Fcom%2Fsksamuel%2Felastic4s%2FScrollTest.scala](https://github.com/sksamuel/elastic4s/blob/master/elastic4s-core%2Fsrc%2Ftest%2Fscala%2Fcom%2Fsksamuel%2Felastic4s%2FScrollTest.scala)

---

<div class="post-metadata">

### Author: ![dpinol](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@dpinol](https://discuss.elastic.co/u/dpinol)
#### Post date: [February 20, 2017, 6:38am UTC](https://discuss.elastic.co/t/how-to-do-scan-and-scroll-using-elastic4s/25458/3 "2017-02-20T06:38:35Z")

</div>

I guess the updated link is [https://github.com/sksamuel/elastic4s/blob/master/elastic4s-tests/src/test/scala/com/sksamuel/elastic4s/search/ScrollHttpTest.scala](https://github.com/sksamuel/elastic4s/blob/master/elastic4s-tests/src/test/scala/com/sksamuel/elastic4s/search/ScrollHttpTest.scala) or [https://github.com/sksamuel/elastic4s/blob/master/elastic4s-tests/src/test/scala/com/sksamuel/elastic4s/search/ScrollTcpTest.scala](https://github.com/sksamuel/elastic4s/blob/master/elastic4s-tests/src/test/scala/com/sksamuel/elastic4s/search/ScrollTcpTest.scala)

---

<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: [July 5, 2017, 10:03pm UTC](https://discuss.elastic.co/t/how-to-do-scan-and-scroll-using-elastic4s/25458/4 "2017-07-05T22:03:05Z")

</div>


