diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldSelector.java index aae7548b32b..3d689a456b5 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldSelector.java @@ -24,8 +24,6 @@ import org.elasticsearch.common.lucene.document.ResetFieldSelector; /** * An optimized field selector that loads just the uid. - * - * */ public class SourceFieldSelector implements ResetFieldSelector { @@ -46,4 +44,9 @@ public class SourceFieldSelector implements ResetFieldSelector { @Override public void reset() { } + + @Override + public String toString() { + return "source"; + } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/mapper/selector/AllButSourceFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/selector/AllButSourceFieldSelector.java index 2f9101a4266..f5943008108 100644 --- a/src/main/java/org/elasticsearch/index/mapper/selector/AllButSourceFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/selector/AllButSourceFieldSelector.java @@ -25,8 +25,6 @@ import org.elasticsearch.index.mapper.internal.SourceFieldMapper; /** * A field selector that loads all fields except the source field. - * - * */ public class AllButSourceFieldSelector implements ResetFieldSelector { @@ -43,4 +41,9 @@ public class AllButSourceFieldSelector implements ResetFieldSelector { @Override public void reset() { } + + @Override + public String toString() { + return "all_but_source"; + } } diff --git a/src/main/java/org/elasticsearch/index/mapper/selector/FieldMappersFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/selector/FieldMappersFieldSelector.java index dc045469b6a..862f48f77af 100644 --- a/src/main/java/org/elasticsearch/index/mapper/selector/FieldMappersFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/selector/FieldMappersFieldSelector.java @@ -54,4 +54,9 @@ public class FieldMappersFieldSelector implements ResetFieldSelector { @Override public void reset() { } + + @Override + public String toString() { + return "fields(" + names + ")"; + } } diff --git a/src/main/java/org/elasticsearch/index/mapper/selector/UidAndRoutingFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/selector/UidAndRoutingFieldSelector.java index 4fd3395d868..80886bdb9a8 100644 --- a/src/main/java/org/elasticsearch/index/mapper/selector/UidAndRoutingFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/selector/UidAndRoutingFieldSelector.java @@ -52,4 +52,9 @@ public class UidAndRoutingFieldSelector implements ResetFieldSelector { public void reset() { match = 0; } + + @Override + public String toString() { + return "uid_and_routing"; + } } diff --git a/src/main/java/org/elasticsearch/index/mapper/selector/UidAndSourceFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/selector/UidAndSourceFieldSelector.java index 3c7d6924963..53a42eb8b86 100644 --- a/src/main/java/org/elasticsearch/index/mapper/selector/UidAndSourceFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/selector/UidAndSourceFieldSelector.java @@ -26,8 +26,6 @@ import org.elasticsearch.index.mapper.internal.UidFieldMapper; /** * An optimized field selector that loads just the uid and the source. - * - * */ public class UidAndSourceFieldSelector implements ResetFieldSelector { @@ -54,4 +52,9 @@ public class UidAndSourceFieldSelector implements ResetFieldSelector { public void reset() { match = 0; } + + @Override + public String toString() { + return "uid_and_source"; + } } diff --git a/src/main/java/org/elasticsearch/index/mapper/selector/UidFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/selector/UidFieldSelector.java index f9b18d77c89..8da00802873 100644 --- a/src/main/java/org/elasticsearch/index/mapper/selector/UidFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/selector/UidFieldSelector.java @@ -25,8 +25,6 @@ import org.elasticsearch.index.mapper.internal.UidFieldMapper; /** * An optimized field selector that loads just the uid. - * - * */ public class UidFieldSelector implements ResetFieldSelector { @@ -47,4 +45,9 @@ public class UidFieldSelector implements ResetFieldSelector { @Override public void reset() { } + + @Override + public String toString() { + return "uid"; + } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java b/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java index 3caeaf4a53a..5a76b541977 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java +++ b/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java @@ -156,7 +156,7 @@ public class FetchPhase implements SearchPhase { for (int index = 0; index < context.docIdsToLoadSize(); index++) { int docId = context.docIdsToLoad()[context.docIdsToLoadFrom() + index]; Document doc = loadDocument(context, fieldSelector, docId); - Uid uid = extractUid(context, doc); + Uid uid = extractUid(context, doc, fieldSelector); DocumentMapper documentMapper = context.mapperService().documentMapper(uid.type()); @@ -268,8 +268,7 @@ public class FetchPhase implements SearchPhase { return null; } - private Uid extractUid(SearchContext context, Document doc) { - // TODO we might want to use FieldData here to speed things up, so we don't have to load it at all... + private Uid extractUid(SearchContext context, Document doc, @Nullable ResetFieldSelector fieldSelector) { String sUid = doc.get(UidFieldMapper.NAME); if (sUid != null) { return Uid.createUid(sUid); @@ -279,7 +278,7 @@ public class FetchPhase implements SearchPhase { 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 + "]"); + throw new FetchPhaseExecutionException(context, "Failed to load uid from the index, missing internal _uid field, current fields in the doc [" + fieldNames + "], selector [" + fieldSelector + "]"); } private Document loadDocument(SearchContext context, @Nullable ResetFieldSelector fieldSelector, int docId) {