better failure message when failing to load _uid field
This commit is contained in:
parent
12a644c89b
commit
eb954a6157
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,4 +54,9 @@ public class FieldMappersFieldSelector implements ResetFieldSelector {
|
|||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "fields(" + names + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,4 +52,9 @@ public class UidAndRoutingFieldSelector implements ResetFieldSelector {
|
|||
public void reset() {
|
||||
match = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "uid_and_routing";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue