improve failure message when not finding _uid field in the doc

This commit is contained in:
kimchy 2011-07-08 03:56:46 +03:00
parent 42edd0c864
commit 9876fa5a76
1 changed files with 7 additions and 2 deletions

View File

@ -53,6 +53,7 @@ import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -172,8 +173,12 @@ public class FetchPhase implements SearchPhase {
if (sUid != null) { if (sUid != null) {
return Uid.createUid(sUid); return Uid.createUid(sUid);
} }
// no type, nothing to do (should not really happen // no type, nothing to do (should not really happen)
throw new FetchPhaseExecutionException(context, "Failed to load uid from the index"); List<String> fieldNames = new ArrayList<String>();
for (Fieldable field : doc.getFields()) {
fieldNames.add(field.name());
}
throw new FetchPhaseExecutionException(context, "Failed to load uid from the index, missing internal _uid field, current fields in the doc [" + fieldNames + "]");
} }
private Document loadDocument(SearchContext context, FieldSelector fieldSelector, int docId) { private Document loadDocument(SearchContext context, FieldSelector fieldSelector, int docId) {