From 9876fa5a76b7ddcf028d9323b6983ed7715a792b Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 8 Jul 2011 03:56:46 +0300 Subject: [PATCH] improve failure message when not finding _uid field in the doc --- .../java/org/elasticsearch/search/fetch/FetchPhase.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java index 098ef5fb76e..3d2b3572524 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java @@ -53,6 +53,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -172,8 +173,12 @@ public class FetchPhase implements SearchPhase { if (sUid != null) { return Uid.createUid(sUid); } - // no type, nothing to do (should not really happen - throw new FetchPhaseExecutionException(context, "Failed to load uid from the index"); + // no type, nothing to do (should not really happen) + List fieldNames = new ArrayList(); + 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) {