Skip to content

Commit 0523ff8

Browse files
committed
better failure message when failing to find a type mapping for a document loaded from the index
1 parent 1661c33 commit 0523ff8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/indices/TypeMissingException.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public TypeMissingException(Index index, String type) {
3232
super(index, "type[" + type + "] missing");
3333
}
3434

35+
public TypeMissingException(Index index, String type, String message) {
36+
super(index, "type[" + type + "] missing: " + message);
37+
}
38+
3539

3640
@Override public RestStatus status() {
3741
return RestStatus.NOT_FOUND;

modules/elasticsearch/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
import org.apache.lucene.index.IndexReader;
2626
import org.elasticsearch.common.collect.ImmutableMap;
2727
import org.elasticsearch.common.inject.Inject;
28+
import org.elasticsearch.index.Index;
2829
import org.elasticsearch.index.mapper.*;
30+
import org.elasticsearch.indices.TypeMissingException;
2931
import org.elasticsearch.search.SearchHitField;
3032
import org.elasticsearch.search.SearchParseElement;
3133
import org.elasticsearch.search.SearchPhase;
@@ -79,6 +81,10 @@ public void execute(SearchContext context) {
7981

8082
DocumentMapper documentMapper = context.mapperService().documentMapper(uid.type());
8183

84+
if (documentMapper == null) {
85+
throw new TypeMissingException(new Index(context.shardTarget().index()), uid.type(), "failed to find type loaded for doc [" + uid.id() + "]");
86+
}
87+
8288
byte[] source = extractSource(doc, documentMapper);
8389

8490
// get the version

0 commit comments

Comments
 (0)