mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 18:35:25 +00:00
better failure message when failing to find a type mapping for a document loaded from the index
This commit is contained in:
parent
3b967040da
commit
d395c0a844
@ -32,6 +32,10 @@ public class TypeMissingException extends IndexException {
|
||||
super(index, "type[" + type + "] missing");
|
||||
}
|
||||
|
||||
public TypeMissingException(Index index, String type, String message) {
|
||||
super(index, "type[" + type + "] missing: " + message);
|
||||
}
|
||||
|
||||
|
||||
@Override public RestStatus status() {
|
||||
return RestStatus.NOT_FOUND;
|
||||
|
@ -25,7 +25,9 @@ import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.indices.TypeMissingException;
|
||||
import org.elasticsearch.search.SearchHitField;
|
||||
import org.elasticsearch.search.SearchParseElement;
|
||||
import org.elasticsearch.search.SearchPhase;
|
||||
@ -79,6 +81,10 @@ public class FetchPhase implements SearchPhase {
|
||||
|
||||
DocumentMapper documentMapper = context.mapperService().documentMapper(uid.type());
|
||||
|
||||
if (documentMapper == null) {
|
||||
throw new TypeMissingException(new Index(context.shardTarget().index()), uid.type(), "failed to find type loaded for doc [" + uid.id() + "]");
|
||||
}
|
||||
|
||||
byte[] source = extractSource(doc, documentMapper);
|
||||
|
||||
// get the version
|
||||
|
Loading…
x
Reference in New Issue
Block a user