diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/FieldValueFeatureExtractor.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/FieldValueFeatureExtractor.java index 5a2e3d29df94..9014c79f0af9 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/FieldValueFeatureExtractor.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ltr/FieldValueFeatureExtractor.java @@ -53,7 +53,10 @@ public void setNextReader(LeafReaderContext segmentContext) { public void addFeatures(Map featureMap, int docId) throws IOException { Source source = sourceLookup.getSource(this.segmentContext, docId); for (FieldValueFetcher vf : this.valueFetcherList) { - featureMap.put(vf.fieldName(), vf.valueFetcher().fetchValues(source, docId, new ArrayList<>()).get(0)); + List values = vf.valueFetcher().fetchValues(source, docId, new ArrayList<>()); + if (values.isEmpty() == false) { + featureMap.put(vf.fieldName(), values.get(0)); + } } }