# Reindex using scroll api

**URL:** <https://discuss.elastic.co/t/reindex-using-scroll-api/39752>\
**Category:** Elasticsearch\
**Created:** [January 21, 2016, 10:09am UTC](https://discuss.elastic.co/t/reindex-using-scroll-api/39752 "2016-01-21T10:09:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cirot87](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cirot87](https://discuss.elastic.co/u/cirot87)\
**Post date:** [January 21, 2016, 10:09am UTC](https://discuss.elastic.co/t/reindex-using-scroll-api/39752/1 "2016-01-21T10:09:43Z")

</div>

Hi, The scope is that i want to reindex my document.

I have the last version of Elasticsearch, in the documentation i see that i need to use scroll api and bulk api (i know how to use them),

The first question is: Can i use "search\_type=scan" on the first search or it is deprecated ?  
i see this : [https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking\_21\_search\_changes.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_21_search_changes.html)

The second question is: When i use scroll search wiht scroll id and i have less than 10 documents i have no results (ex. hits[] ) but if i have more than 10 doc i have results. How it's possible? There is some settings to change?

I'm doing a normal query:

POST /region/city/\_search?scroll=1m  
{  
"size":1000,  
"sort": ["\_doc"],  
"query" : {  
"match\_all" : {}  
}  
}

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [January 21, 2016, 10:12pm UTC](https://discuss.elastic.co/t/reindex-using-scroll-api/39752/2 "2016-01-21T22:12:25Z")

</div>

> [@cirot87](#):
>
> Can i use "search\_type=scan" on the first search or it is deprecated ?

It is deprecated indeed. What you do with a scroll request that sorts on \_doc is the right thing to do.

> [@cirot87](#):
>
> The second question is: When i use scroll search wiht scroll id and i have less than 10 documents i have no results (ex. hits ) but if i have more than 10 doc i have results. How it's possible? There is some settings to change?

Maybe you are confused because a simple scroll already returns documents on the first request (on the contrary to scans which used to only count results on the first request and would only return hits on further calls to the scroll api).

---

<div class="post-metadata">

**Author:** ![cirot87](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cirot87](https://discuss.elastic.co/u/cirot87)\
**Post date:** [January 22, 2016, 8:36am UTC](https://discuss.elastic.co/t/reindex-using-scroll-api/39752/3 "2016-01-22T08:36:03Z")

</div>

ty for answer .

> [@jpountz](#):
>
> Maybe you are confused because a simple scroll already returns documents on the first request (on the contrary to scans which used to only count results on the first request and would only return hits on further calls to the scroll api).

Now, i have a new question...if i use the scroll api or a normal search on my alias for a "match\_all" query with the maximum size of the index...i have the same result...

So in this case the scroll api is useless becouse i can use a normal query on alias save the data then use the bulk api for insert them on the new index.

If i'm on the correct way....what is the utility to use the scroll api for reindex (recommended on the documentation of ES)?

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [January 22, 2016, 8:50am UTC](https://discuss.elastic.co/t/reindex-using-scroll-api/39752/4 "2016-01-22T08:50:45Z")

</div>

The utility is that a regular search operation is very bad at fetching lots of records at once. It might work in your case if you don't have many documents, but otherwise the fact that it needs to fetch all matching documents and put them in a single json document will likely make your system go out of memory.

---

<div class="post-metadata">

**Author:** ![cirot87](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cirot87](https://discuss.elastic.co/u/cirot87)\
**Post date:** [January 22, 2016, 9:06am UTC](https://discuss.elastic.co/t/reindex-using-scroll-api/39752/5 "2016-01-22T09:06:55Z")

</div>

right, but for use scroll api i need to do a lot number of query for take all results, this can be slowed; and for use \_search/scroll...before i need to do another query \_search?scroll=1m for active the scroll\_id (this isn't consistent for me).

So i have a large number of scroll query or a big json document and in both cases my system can go out of memory.

I forget something or it's right?

---

<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, 11:22pm UTC](https://discuss.elastic.co/t/reindex-using-scroll-api/39752/6 "2017-07-05T23:22:18Z")

</div>


