# Reindex failed: search\_context\_missing\_exception

**URL:** <https://discuss.elastic.co/t/reindex-failed-search-context-missing-exception/262992>\
**Category:** Elasticsearch\
**Tags:** reindex\
**Created:** [February 2, 2021, 1:53pm UTC](https://discuss.elastic.co/t/reindex-failed-search-context-missing-exception/262992 "2021-02-02T13:53:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangxr1985](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wangxr1985/32/117798_2.png) [@wangxr1985](https://discuss.elastic.co/u/wangxr1985)\
**Post date:** [February 2, 2021, 1:53pm UTC](https://discuss.elastic.co/t/reindex-failed-search-context-missing-exception/262992/1 "2021-02-02T13:53:53Z")

</div>

I want to migrate a index from es5 cluster to es7 cluster by using remote reindexing.  
The number of docs is 5,000,000.  
I use curl to call the \_reindex api like this:

```auto
curl -uelastic:xxx -XPOST -H 'Content-Type: application/json' http://127.0.0.1:9200/_reindex?scroll=60m\&wait_for_completion=false -d'
{
    "source": {
    "remote": {
        "host": "http://1.1.1.1:9200",
        "username": "elastic",
        "password": "xxx"
    },
    "index": "my_index",
    "size": 8000
  },
  "dest": {
    "index": "my_index"
  }
}'

```

I tried several times but all the tasks failed quickly after 10-20 batches. They have the same error:search\_context\_missing\_exception.  
I know the error often occurs when the scroll context is removed for expiring.I have set the scroll=60m and the speed of reindexing is very fast.

```auto
"error": { - 
    "type": "status_exception",
    "reason": "body={\"error\":{\"root_cause\":[{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5531730953]\"},{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5531730954]\"},{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5715500036]\"}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"query\",\"grouped\":true,\"failed_shards\":[{\"shard\":-1,\"index\":null,\"reason\":{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5531730953]\"}},{\"shard\":-1,\"index\":null,\"reason\":{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5531730954]\"}},{\"shard\":-1,\"index\":null,\"reason\":{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5715500036]\"}}],\"caused_by\":{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5715500036]\"}},\"status\":404}",
    "caused_by": { - 
      "type": "response_exception",
      "reason": "method [POST], host [http://1.1.1.1:9200], URI [/_search/scroll?scroll=3600000000000nanos], status line [HTTP/1.1 404 Not Found]\n{\"error\":{\"root_cause\":[{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5531730953]\"},{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5531730954]\"},{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5715500036]\"}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"query\",\"grouped\":true,\"failed_shards\":[{\"shard\":-1,\"index\":null,\"reason\":{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5531730953]\"}},{\"shard\":-1,\"index\":null,\"reason\":{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5531730954]\"}},{\"shard\":-1,\"index\":null,\"reason\":{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5715500036]\"}}],\"caused_by\":{\"type\":\"search_context_missing_exception\",\"reason\":\"No search context found for id [5715500036]\"}},\"status\":404}"
    }

```

---

<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:** [March 2, 2021, 1:54pm UTC](https://discuss.elastic.co/t/reindex-failed-search-context-missing-exception/262992/2 "2021-03-02T13:54:17Z")

</div>

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