Skip to content

Apache Lucene open-source search software

Fix randomly failing field info format tests (#12473)

Benjamin Trent229dc7481ef7
diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/index/BaseFieldInfoFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/tests/index/BaseFieldInfoFormatTestCase.java
index 7a054c290c3..b3bd9656171 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/index/BaseFieldInfoFormatTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/index/BaseFieldInfoFormatTestCase.java
@@ -354,7 +354,7 @@ public abstract class BaseFieldInfoFormatTestCase extends BaseIndexFileFormatTes
type.setDimensions(dimension, indexDimension, dimensionNumBytes);
}
- if (r.nextBoolean()) {
+ if (r.nextBoolean() && getVectorsMaxDimensions(fieldName) > 0) {
int dimension = 1 + r.nextInt(getVectorsMaxDimensions(fieldName));
VectorSimilarityFunction similarityFunction =
RandomPicks.randomFrom(r, VectorSimilarityFunction.values());