Failed to build inner hits – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Before you dig into reading this guide, have you tried asking OpsGPT what this log means? You’ll receive a customized analysis of your log.

Try OpsGPT now for step-by-step guidance and tailored insights into your Elasticsearch operation.

Briefly, this error occurs when Elasticsearch fails to construct the inner_hits part of a query. Inner_hits is used to return nested or child documents. This could be due to incorrect syntax, a non-existent field, or a problem with the nested data structure. To resolve this, ensure that the field you’re querying exists and is correctly nested. Also, check your query syntax for any errors. If the problem persists, consider reindexing your data to ensure the nested structure is correct.

For a complete solution to your to your search operation, try for free AutoOps for Elasticsearch & OpenSearch . With AutoOps and Opster’s proactive support, you don’t have to worry about your search operation – we take charge of it. Get improved performance & stability with less hardware.

This guide will help you check for common problems that cause the log ” failed to build inner_hits ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search.

Log Context

Log “failed to build inner_hits” class name is We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 if (innerHitBuilders.size() > 0) {
 for (Map.Entry entry : innerHitBuilders.entrySet()) {
 try {
 entry.getValue().build(context; context.innerHits());
 } catch (IOException e) {
 throw new SearchException(shardTarget; "failed to build inner_hits"; e);
 if (source.sorts() != null) {
 try {


How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Get expert answers on Elasticsearch/OpenSearch