diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index ec80aece376..a9ab28ac062 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -430,6 +430,8 @@ Other Changes * SOLR-10851: SolrClients should clarify expectations for solrServerUrl parameter (Jason Gerlowski via Tomás Fernández Löbbe) + +* SOLR-10891: BBoxField should support point-based number sub-fields. (Steve Rowe) * SOLR-10834: Fixed tests and test configs to stop using numeric uniqueKey fields (hossman) diff --git a/solr/core/src/java/org/apache/solr/schema/BBoxField.java b/solr/core/src/java/org/apache/solr/schema/BBoxField.java index 4d773c96ac4..957059f840e 100644 --- a/solr/core/src/java/org/apache/solr/schema/BBoxField.java +++ b/solr/core/src/java/org/apache/solr/schema/BBoxField.java @@ -89,8 +89,11 @@ public class BBoxField extends AbstractSpatialFieldType implements if (!(booleanType instanceof BoolField)) { throw new RuntimeException("Must be a BoolField: " + booleanType); } - if (!(numberType instanceof TrieDoubleField)) { // TODO support TrieField (any trie) once BBoxStrategy does - throw new RuntimeException("Must be TrieDoubleField: " + numberType); + if (numberType.getNumberType() != NumberType.DOUBLE) { + throw new RuntimeException("Must be Double number type: " + numberType); + } + if ( ! numberType.hasProperty(DOC_VALUES)) { + throw new RuntimeException("Must have doc values: " + numberType); } //note: this only works for explicit fields, not dynamic fields @@ -138,6 +141,9 @@ public class BBoxField extends AbstractSpatialFieldType implements final SchemaField solrNumField = new SchemaField("_", numberType);//dummy temp org.apache.lucene.document.FieldType luceneType = (org.apache.lucene.document.FieldType) solrNumField.createField(0.0).fieldType(); + if ( ! (luceneType instanceof LegacyFieldType)) { + luceneType = new org.apache.lucene.document.FieldType(luceneType); + } luceneType.setStored(storeSubFields); //and annoyingly this Field isn't going to have a docValues format because Solr uses a separate Field for that diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml b/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml index 9c7a36f6b7b..a90fa3d00e0 100644 --- a/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml @@ -24,6 +24,8 @@ + + @@ -54,6 +56,9 @@ + + @@ -65,6 +70,7 @@ + diff --git a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java index 895fb831708..4217a00dee5 100644 --- a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java +++ b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java @@ -53,7 +53,7 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 { @ParametersFactory public static Iterable parameters() { return Arrays.asList(new Object[][]{ - {"llp"}, {"llp_idx"}, {"llp_dv"}, {"srpt_geohash"}, {"srpt_quad"}, {"srpt_packedquad"}, {"stqpt_geohash"}, {"pointvector"}, {"bbox"} + {"llp"}, {"llp_idx"}, {"llp_dv"}, {"srpt_geohash"}, {"srpt_quad"}, {"srpt_packedquad"}, {"stqpt_geohash"}, {"pointvector"}, {"bbox"}, {"pbbox"} }); } @@ -179,7 +179,7 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 { } private void checkHits(String fieldName, boolean exact, String ptStr, double distKM, double sphereRadius, int count, int ... docIds) throws ParseException { - if (exact && fieldName.equalsIgnoreCase("bbox")) { + if (exact && fieldName.equalsIgnoreCase("bbox") | fieldName.equalsIgnoreCase("pbbox")) { return; // bbox field only supports rectangular query } String [] tests = new String[docIds != null && docIds.length > 0 ? docIds.length + 1 : 1]; @@ -369,9 +369,9 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 { private String radiusQuery(double lat, double lon, double dDEG, String score, String filter) { //Choose between the Solr/Geofilt syntax, and the Lucene spatial module syntax - if (fieldName.equals("bbox") || random().nextBoolean()) { + if (fieldName.equals("bbox") || fieldName.equals("pbbox") || random().nextBoolean()) { //we cheat for bbox strategy which doesn't do radius, only rect. - final String qparser = fieldName.equals("bbox") ? "bbox" : "geofilt"; + final String qparser = (fieldName.equals("bbox") || fieldName.equals("pbbox")) ? "bbox" : "geofilt"; return "{!" + qparser + " " + "sfield=" + fieldName + " " + (score != null ? "score="+score : "") + " " @@ -389,7 +389,7 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 { public void testSortMultiVal() throws Exception { assumeTrue("dist sorting not supported on field " + fieldName, canCalcDistance); assumeFalse("Multivalue not supported for this field", - fieldName.equals("pointvector") || fieldName.equals("bbox")); + fieldName.equals("pointvector") || fieldName.equals("bbox") || fieldName.equals("pbbox")); assertU(adoc("id", "100", fieldName, "1,2"));//1 point assertU(adoc("id", "101", fieldName, "4,-1", fieldName, "3,5"));//2 points, 2nd is pretty close to query point