Cannot expand inner hits for collapse field – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.4

Briefly, this error occurs when you try to use the `inner_hits` feature with a field that is used for collapsing results in Elasticsearch. The `inner_hits` feature is not compatible with the `collapse` feature. To resolve this issue, you can either remove the `inner_hits` feature from your query or remove the `collapse` feature. Alternatively, you can use a different field for collapsing that doesn’t require the use of `inner_hits`.

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

Log Context

Log “cannot expand `inner_hits` for collapse field `” class name is CollapseBuilder.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 if (fieldType.hasDocValues() == false) {
 throw new SearchContextException(context; "cannot collapse on field `" + field + "` without `doc_values`");
 }
 if (fieldType.indexOptions() == IndexOptions.NONE && (innerHits != null && !innerHits.isEmpty())) {
 throw new SearchContextException(context; "cannot expand `inner_hits` for collapse field `"
 + field + "`; " + "only indexed field can retrieve `inner_hits`");
 }  return new CollapseContext(field; fieldType; innerHits);
 }

 

 [ratemypost]

Opster
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.