# How to resolve search context missing exception?

**URL:** <https://discuss.elastic.co/t/how-to-resolve-search-context-missing-exception/124465>\
**Category:** Elasticsearch\
**Created:** [March 19, 2018, 12:10am UTC](https://discuss.elastic.co/t/how-to-resolve-search-context-missing-exception/124465 "2018-03-19T00:10:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![majid\_zarrin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majid_zarrin/32/29103_2.png) [@majid\_zarrin](https://discuss.elastic.co/u/majid_zarrin)\
**Post date:** [March 19, 2018, 12:10am UTC](https://discuss.elastic.co/t/how-to-resolve-search-context-missing-exception/124465/1 "2018-03-19T00:10:03Z")

</div>

Hello guys  
I need to create an Index by manipulating another index with java.  
here is my cluster specification:  
ES version: 6.1  
source Index documents count: 1.4 billion  
the cluster had 2 nodes. both of them are data and master  
each node: 50GB RAM, CPU 10\* 2.2 GHz, SSD  
process average speed ( read data from the source index by scrolling + manipulating + indexing in destination index): 250k per minute.  
the problem is after about 1 day that was everything OK, I confront with search\_context\_missing\_exception.

here is the log summary.

> ..  
> proceed : 620910000 / 1437095913  
> proceed : 620915000 / 1437095913  
> proceed : 620920000 / 1437095913  
> Exception in thread "main" ElasticsearchStatusException[Elasticsearch exception [type=search\_phase\_execution\_exception, reason=all shards failed]]; nested: ElasticsearchException[Elasticsearch exception [type=search\_context\_missing\_exception, reason=No search context found for id [235]]];  
> at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)  
> at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:573)  
> at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:549)  
> at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:456)  
> at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:429)  
> at org.elasticsearch.client.RestHighLevelClient.searchScroll(RestHighLevelClient.java:387)  
> at Main.export(Main.java:201)  
> at Main.main(Main.java:71)  
> Suppressed: org.elasticsearch.client.ResponseException: method [GET], host [[https://el6.myserver.ir:443](https://el6.myserver.ir:443)], URI [/\_search/scroll], status line [HTTP/1.1 404 Not Found]  
> {"error":{"root\_cause":[{"type":"search\_context\_missing\_exception","reason":"No search context found for id [229]"},{"type":"search\_context\_missing\_exception","reason":"No search context found for id [224]"},{"type":"search\_context\_missing\_exception","reason":"No search context found for id [223]"}],"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 [229]"}},{"shard":-1,"index":null,"reason":{"type":"search\_context\_missing\_exception","reason":"No search context found for id [235]"}}],"caused\_by":{"type":"search\_context\_missing\_exception","reason":"No search context found for id [235]"}},"status":404}  
> at org.elasticsearch.client.RestClient$1.completed(RestClient.java:357)  
> at org.elasticsearch.client.RestClient$1.completed(RestClient.java:346)  
> at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:119)  
> at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:177)  
> at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:436)  
> at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:326)  
> at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265)  
> at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)  
> at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)  
> at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:121)  
> at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)  
> at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)  
> at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)  
> at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)  
> at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)  
> at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)  
> at java.lang.Thread.run(Thread.java:748)  
> Caused by: ElasticsearchException[Elasticsearch exception [type=search\_context\_missing\_exception, reason=No search context found for id [235]]]  
> at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:490)  
> at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:406)  
> at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:435)  
> at org.elasticsearch.ElasticsearchException.failureFromXContent(ElasticsearchException.java:594)  
> at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:169)  
> ... 7 more  
> Inserting : failed requests[5000], indices[m\_web]ElasticsearchStatusException[Unable to parse response body]; nested: ResponseException[method [POST], host [[https://el1.myserver.ir:443](https://el1.myserver.ir:443)], URI [/\_bulk?timeout=1m], status line [HTTP/1.1 504 Gateway Time-out]

and then I got a strange nginx error in the log :

> The page is temporarily unavailable 
> # **nginx error!**
> 
> ### The page you are looking for is temporarily unavailable. Please try again later.
> 
> ## Website Administrator
> 
> Something has triggered an error on your website. This is the default error page for **nginx** that is distributed with Fedora. It is located /usr/share/nginx/html/50x.html
> 
> You should customize this error page for your own site or edit the error\_page directive in the **nginx** configuration file /etc/nginx/nginx.conf.

and here is search request configuration:

```
    SearchRequest searchRequest = new SearchRequest("myIndex");
    searchRequest.types("myType");
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    searchSourceBuilder.query(QueryBuilders.matchAllQuery());
    searchSourceBuilder.size(5000);
    searchRequest.source(searchSourceBuilder);
    sourceBuilder.timeout(new TimeValue(10, TimeUnit.MINUTES));
    searchRequest.scroll(new TimeValue(10, TimeUnit.MINUTES));

```

I will be appreciated if someone help to resolve the problem.

---

<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:** [April 16, 2018, 12:10am UTC](https://discuss.elastic.co/t/how-to-resolve-search-context-missing-exception/124465/2 "2018-04-16T00:10:04Z")

</div>

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