Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-11345: restrict double field values used for function queries to float range

Steve Rowe5f68eb945626
diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
index 5d2adb4b289..703ddd884b5 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
@@ -3330,7 +3330,14 @@ public class TestPointFields extends SolrTestCaseJ4 {
private void doTestDoublePointFunctionQuery(String field) throws Exception {
assertTrue(h.getCore().getLatestSchema().getField(field).getType() instanceof PointField);
int numVals = 10 * RANDOM_MULTIPLIER;
- List<Double> values = getRandomDoubles(numVals, false);
+ // Restrict values to float range; otherwise conversion to float will cause truncation -> undefined results
+ List<Double> values = getRandomList(10, false, () -> {
+ Float f = Float.NaN;
+ while (f.isNaN()) {
+ f = Float.intBitsToFloat(random().nextInt());
+ }
+ return f.doubleValue();
+ });
String assertNumFound = "//*[@numFound='" + numVals + "']";
String[] idAscXpathChecks = new String[numVals + 1];
String[] idAscNegXpathChecks = new String[numVals + 1];