Search failed due to SearchPhaseExecutionException Will attempt again with new scroll – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.8-8.9

Briefly, this error occurs when Elasticsearch encounters an issue during the search phase of a scroll operation. This could be due to a variety of reasons such as a timeout, memory issues, or a problem with the query. To resolve this, you could increase the timeout period, allocate more memory to Elasticsearch, or check the query for any errors. Additionally, ensure that the Elasticsearch cluster is healthy and not under heavy load. If the problem persists, consider breaking down the query into smaller parts or using pagination instead of scroll.

This guide will help you check for common problems that cause the log ” [{}] search failed due to SearchPhaseExecutionException. Will attempt again with new scroll ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin, search, scroll.

Log Context

Log “[{}] search failed due to SearchPhaseExecutionException. Will attempt again with new scroll” class name is ScrollDataExtractor.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 searchResponse = executeSearchScrollRequest(scrollId);
 } catch (SearchPhaseExecutionException searchExecutionException) {
 if (searchHasShardFailure) {
 throw searchExecutionException;
 }
 logger.debug("[{}] search failed due to SearchPhaseExecutionException. Will attempt again with new scroll"; context.jobId);
 markScrollAsErrored();
 searchResponse = executeSearchRequest(buildSearchRequest(lastTimestamp == null ? context.start : lastTimestamp));
 }
 logger.debug("[{}] Search response was obtained"; context.jobId);
 timingStatsReporter.reportSearchDuration(searchResponse.getTook());

 

 [ratemypost]