diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/bytes/MultiValueByteFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/bytes/MultiValueByteFieldData.java index 67b06edff91..e68b1cd5ad8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/bytes/MultiValueByteFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/bytes/MultiValueByteFieldData.java @@ -155,8 +155,16 @@ public class MultiValueByteFieldData extends ByteFieldData { } @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + boolean found = false; for (int[] ordinal : ordinals) { - proc.onOrdinal(docId, ordinal[docId]); + int loc = ordinal[docId]; + if (loc != 0) { + found = true; + proc.onOrdinal(docId, ordinal[docId]); + } + } + if (!found) { + proc.onOrdinal(docId, 0); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/MultiValueDoubleFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/MultiValueDoubleFieldData.java index d926b5aca74..92426e3667e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/MultiValueDoubleFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/MultiValueDoubleFieldData.java @@ -144,8 +144,16 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { } @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + boolean found = false; for (int[] ordinal : ordinals) { - proc.onOrdinal(docId, ordinal[docId]); + int loc = ordinal[docId]; + if (loc != 0) { + found = true; + proc.onOrdinal(docId, ordinal[docId]); + } + } + if (!found) { + proc.onOrdinal(docId, 0); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/MultiValueFloatFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/MultiValueFloatFieldData.java index c7b6ea5620b..a1ed1c15a9a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/MultiValueFloatFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/MultiValueFloatFieldData.java @@ -155,8 +155,16 @@ public class MultiValueFloatFieldData extends FloatFieldData { } @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + boolean found = false; for (int[] ordinal : ordinals) { - proc.onOrdinal(docId, ordinal[docId]); + int loc = ordinal[docId]; + if (loc != 0) { + found = true; + proc.onOrdinal(docId, ordinal[docId]); + } + } + if (!found) { + proc.onOrdinal(docId, 0); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/MultiValueIntFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/MultiValueIntFieldData.java index 54b0ea0957c..dad25b498fb 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/MultiValueIntFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/MultiValueIntFieldData.java @@ -155,8 +155,16 @@ public class MultiValueIntFieldData extends IntFieldData { } @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + boolean found = false; for (int[] ordinal : ordinals) { - proc.onOrdinal(docId, ordinal[docId]); + int loc = ordinal[docId]; + if (loc != 0) { + found = true; + proc.onOrdinal(docId, ordinal[docId]); + } + } + if (!found) { + proc.onOrdinal(docId, 0); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java index c983c0f975c..4b36631373d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java @@ -157,8 +157,16 @@ public class MultiValueLongFieldData extends LongFieldData { } @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + boolean found = false; for (int[] ordinal : ordinals) { - proc.onOrdinal(docId, ordinal[docId]); + int loc = ordinal[docId]; + if (loc != 0) { + found = true; + proc.onOrdinal(docId, ordinal[docId]); + } + } + if (!found) { + proc.onOrdinal(docId, 0); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/MultiValueShortFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/MultiValueShortFieldData.java index ad99df8802a..322243aa3de 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/MultiValueShortFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/MultiValueShortFieldData.java @@ -155,8 +155,16 @@ public class MultiValueShortFieldData extends ShortFieldData { } @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + boolean found = false; for (int[] ordinal : ordinals) { - proc.onOrdinal(docId, ordinal[docId]); + int loc = ordinal[docId]; + if (loc != 0) { + found = true; + proc.onOrdinal(docId, ordinal[docId]); + } + } + if (!found) { + proc.onOrdinal(docId, 0); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/MultiValueStringFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/MultiValueStringFieldData.java index 589cf6bebba..a0264c9aef9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/MultiValueStringFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/MultiValueStringFieldData.java @@ -85,8 +85,16 @@ public class MultiValueStringFieldData extends StringFieldData { } @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + boolean found = false; for (int[] ordinal : ordinals) { - proc.onOrdinal(docId, ordinal[docId]); + int loc = ordinal[docId]; + if (loc != 0) { + found = true; + proc.onOrdinal(docId, ordinal[docId]); + } + } + if (!found) { + proc.onOrdinal(docId, 0); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/geo/MultiValueGeoPointFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/geo/MultiValueGeoPointFieldData.java index 561308c3010..84b6830f70e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/geo/MultiValueGeoPointFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/geo/MultiValueGeoPointFieldData.java @@ -118,8 +118,16 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { } @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + boolean found = false; for (int[] ordinal : ordinals) { - proc.onOrdinal(docId, ordinal[docId]); + int loc = ordinal[docId]; + if (loc != 0) { + found = true; + proc.onOrdinal(docId, ordinal[docId]); + } + } + if (!found) { + proc.onOrdinal(docId, 0); } }