You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2014/07/09 22:31:38 UTC
svn commit: r1609291 - in /lucene/dev/trunk/solr:
core/src/java/org/apache/solr/schema/BBoxField.java
core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
example/solr/collection1/conf/schema.xml
Author: dsmiley
Date: Wed Jul 9 20:31:37 2014
New Revision: 1609291
URL: http://svn.apache.org/r1609291
Log:
SOLR-6183: bug, BBoxField didn't propagate docValues configuration.
And numberType is now a required attribute.
Modified:
lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/BBoxField.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
lucene/dev/trunk/solr/example/solr/collection1/conf/schema.xml
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/BBoxField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/BBoxField.java?rev=1609291&r1=1609290&r2=1609291&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/BBoxField.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/BBoxField.java Wed Jul 9 20:31:37 2014
@@ -18,11 +18,13 @@ package org.apache.solr.schema;
*/
import com.spatial4j.core.shape.Rectangle;
+import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.spatial.bbox.BBoxOverlapRatioValueSource;
import org.apache.lucene.spatial.bbox.BBoxStrategy;
import org.apache.lucene.spatial.query.SpatialArgs;
import org.apache.lucene.spatial.util.ShapeAreaValueSource;
+import org.apache.solr.common.SolrException;
import org.apache.solr.search.QParser;
import java.util.ArrayList;
@@ -32,7 +34,7 @@ import java.util.Map;
public class BBoxField extends AbstractSpatialFieldType<BBoxStrategy> implements SchemaAware {
private static final String PARAM_QUERY_TARGET_PROPORTION = "queryTargetProportion";
private static final String PARAM_MIN_SIDE_LENGTH = "minSideLength";
- private String numberFieldName = "tdouble";
+ private String numberFieldName;//required
private String booleanFieldName = "boolean";
private IndexSchema schema;
@@ -42,9 +44,11 @@ public class BBoxField extends AbstractS
super.init(schema, args);
String v = args.remove("numberType");
- if (v != null) {
- numberFieldName = v;
+ if (v == null) {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "The field type: " + typeName
+ + " must specify the numberType attribute.");
}
+ numberFieldName = v;
v = args.remove("booleanType");
if (v != null) {
@@ -92,9 +96,16 @@ public class BBoxField extends AbstractS
@Override
protected BBoxStrategy newSpatialStrategy(String s) {
BBoxStrategy strategy = new BBoxStrategy(ctx, s);
- //Solr's FieldType ought to expose Lucene FieldType. Instead as a hack we create a field with a dummy value.
+ //Solr's FieldType ought to expose Lucene FieldType. Instead as a hack we create a Field with a dummy value.
SchemaField field = schema.getField(strategy.getFieldName() + BBoxStrategy.SUFFIX_MINX);
- strategy.setFieldType((org.apache.lucene.document.FieldType) field.createField(0.0, 1.0f).fieldType());
+ org.apache.lucene.document.FieldType luceneType =
+ (org.apache.lucene.document.FieldType) field.createField(0.0, 1.0f).fieldType();
+ //and annoyingly this field isn't going to have a docValues format because Solr uses a separate Field for that
+ if (field.hasDocValues()) {
+ luceneType = new org.apache.lucene.document.FieldType(luceneType);
+ luceneType.setDocValueType(FieldInfo.DocValuesType.NUMERIC);
+ }
+ strategy.setFieldType(luceneType);
return strategy;
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java?rev=1609291&r1=1609290&r2=1609291&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java Wed Jul 9 20:31:37 2014
@@ -17,12 +17,15 @@ package org.apache.solr.search;
* limitations under the License.
*/
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
//Unlike TestSolr4Spatial, not parameterized / not generic.
+//We exclude Codecs that don't support DocValues (though not sure if this list is quite right)
+@LuceneTestCase.SuppressCodecs({"Lucene3x", "Appending", "Lucene40", "Lucene41"})
public class TestSolr4Spatial2 extends SolrTestCaseJ4 {
@BeforeClass
Modified: lucene/dev/trunk/solr/example/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/collection1/conf/schema.xml?rev=1609291&r1=1609290&r2=1609291&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/trunk/solr/example/solr/collection1/conf/schema.xml Wed Jul 9 20:31:37 2014
@@ -709,9 +709,11 @@
geo="true" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />
<!-- Spatial rectangle (bounding box) field. It supports most spatial predicates, and has
- special relevancy modes: score=overlapRatio|area|area2D (local-param to the query)-->
+ special relevancy modes: score=overlapRatio|area|area2D (local-param to the query). DocValues is recommended for
+ relevancy. -->
<fieldType name="bbox" class="solr.BBoxField"
- geo="true" units="degrees" numberType="tdouble" />
+ geo="true" units="degrees" numberType="_bbox_coord" />
+ <fieldType name="_bbox_coord" class="solr.TrieDoubleField" precisionStep="8" docValues="true" stored="false"/>
<!-- Money/currency field type. See http://wiki.apache.org/solr/MoneyFieldType
Parameters: