# Scrolling using the Scala API to ES

**URL:** <https://discuss.elastic.co/t/scrolling-using-the-scala-api-to-es/20697>\
**Category:** Elasticsearch\
**Created:** [November 11, 2014, 9:00pm UTC](https://discuss.elastic.co/t/scrolling-using-the-scala-api-to-es/20697 "2014-11-11T21:00:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)\
**Post date:** [November 11, 2014, 9:00pm UTC](https://discuss.elastic.co/t/scrolling-using-the-scala-api-to-es/20697/1 "2014-11-11T21:00:15Z")

</div>

Hi:  
What is the syntax for using the scroll API for searches using the  
scala interface (elastic4s) ?  
I am not able to find suitable documentation for this and any help is  
appreciated.

Thanks

Ramdev

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c18a9fb0-b794-41f4-89e2-b1cc0e74fd24%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c18a9fb0-b794-41f4-89e2-b1cc0e74fd24%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)\
**Post date:** [November 12, 2014, 3:01pm UTC](https://discuss.elastic.co/t/scrolling-using-the-scala-api-to-es/20697/2 "2014-11-12T15:01:10Z")

</div>

ok, So I figured this bit out with a few provisos........ ( there wasn't a  
test that covered this case in the UnitTests)

Build the Search Requests like so :

{  
search in "index/type" query  
{  
matchQuery("FIELD", field\_value)  
} scroll (KeepAlive - duration using ES duration syntax for eg: 1m -  
indicating 1minute)  
}.build

Once the query is built, the first query is executed like so :

client.execute(query)

The SearchResponse from the future returned, from executing the Query,  
also returned a ScrollId

searchResponse.getScrollId

Subsequent Queries (to get scroll through the rest of the full results of  
the query :

client.searchScroll(searchResponse.getScrollId,KeepAlive)

Keep in mind that the scrollId needs to be retrieved after each search  
scroll call.

Even tho' there were two calls allowed for search scroll

client.searchScroll(scrollId) _and_  
client.searchScroll(scrollId,KeepAlive)

Only the 2nd call actually worked in my case. the first call went thought  
the first execution, and 2nd execution. But failed to return a scold on  
the 2nd time around and so it failed to proceed beyond that point.

That said, if someone is able to point out why a KeepAlive parameter needs  
to be passed (contrary to what ES' s site defines how scroll works)

Thanks

Ramdev

On Tuesday, 11 November 2014 15:00:15 UTC-6, Ramdev Wudali wrote:

> Hi:  
> What is the syntax for using the scroll API for searches using the  
> scala interface (elastic4s) ?  
> I am not able to find suitable documentation for this and any help is  
> appreciated.
> 
> Thanks
> 
> Ramdev

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8d8e40c4-149a-4c53-9753-a01839852478%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8d8e40c4-149a-4c53-9753-a01839852478%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [February 16, 2015, 5:54am UTC](https://discuss.elastic.co/t/scrolling-using-the-scala-api-to-es/20697/3 "2015-02-16T05:54:33Z")

</div>

I've added an issue to clarify the usage of the scroll syntax in elastic4s.

> <https://github.com/sksamuel/elastic4s/issues/273>
>
> https://groups.google.com/forum/#!searchin/elasticsearch/elastic4s|sort:date/ela…sticsearch/zVkjRDKNvP4/W-XxD8WN6sYJ

On Wednesday, November 12, 2014 at 3:01:10 PM UTC, Ramdev Wudali wrote:

> ok, So I figured this bit out with a few provisos........ ( there wasn't  
> a test that covered this case in the UnitTests)
> 
> Build the Search Requests like so :
> 
> {  
> search in "index/type" query  
> {  
> matchQuery("FIELD", field\_value)  
> } scroll (KeepAlive - duration using ES duration syntax for eg: 1m -  
> indicating 1minute)  
> }.build
> 
> Once the query is built, the first query is executed like so :
> 
> client.execute(query)
> 
> The SearchResponse from the future returned, from executing the Query,  
> also returned a ScrollId
> 
> searchResponse.getScrollId
> 
> Subsequent Queries (to get scroll through the rest of the full results of  
> the query :
> 
> client.searchScroll(searchResponse.getScrollId,KeepAlive)
> 
> Keep in mind that the scrollId needs to be retrieved after each search  
> scroll call.
> 
> Even tho' there were two calls allowed for search scroll
> 
> client.searchScroll(scrollId) _and_  
> client.searchScroll(scrollId,KeepAlive)
> 
> Only the 2nd call actually worked in my case. the first call went thought  
> the first execution, and 2nd execution. But failed to return a scold on  
> the 2nd time around and so it failed to proceed beyond that point.
> 
> That said, if someone is able to point out why a KeepAlive parameter  
> needs to be passed (contrary to what ES' s site defines how scroll works)
> 
> Thanks
> 
> Ramdev
> 
> On Tuesday, 11 November 2014 15:00:15 UTC-6, Ramdev Wudali wrote:
> 
> > Hi:  
> > What is the syntax for using the scroll API for searches using the  
> > scala interface (elastic4s) ?  
> > I am not able to find suitable documentation for this and any help is  
> > appreciated.
> > 
> > Thanks
> > 
> > Ramdev

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5bfa31a4-bfe5-4c7d-bfc1-387de4ae32f2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5bfa31a4-bfe5-4c7d-bfc1-387de4ae32f2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:32am UTC](https://discuss.elastic.co/t/scrolling-using-the-scala-api-to-es/20697/4 "2017-07-06T00:32:37Z")

</div>


