No mapping found for field in order to collapse on – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.4

Briefly, this error occurs when Elasticsearch tries to collapse results based on a field that doesn’t exist in the mapping of the index. The field you’re trying to collapse on is not recognized by Elasticsearch. To resolve this issue, you can either add the missing field to the index mapping or change the field you’re trying to collapse on to a field that exists in the index mapping. Also, ensure that the field you’re collapsing on is not an analyzed field as Elasticsearch does not support collapsing on analyzed fields.

This guide will help you check for common problems that cause the log ” no mapping found for `” + field + “` in order to collapse on ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search, mapping.

Log Context

Log “no mapping found for `” + field + “` in order to collapse on” class name is CollapseBuilder.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 throw new SearchContextException(context; "cannot use `collapse` in conjunction with `rescore`");
 }  MappedFieldType fieldType = context.getQueryShardContext().fieldMapper(field);
 if (fieldType == null) {
 throw new SearchContextException(context; "no mapping found for `" + field + "` in order to collapse on");
 }
 if (fieldType instanceof KeywordFieldMapper.KeywordFieldType == false &&
 fieldType instanceof NumberFieldMapper.NumberFieldType == false) {
 throw new SearchContextException(context; "unknown type for collapse field `" + field +
 "`; only keywords and numbers are accepted");

 

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?