mirror of https://github.com/apache/lucene.git
SOLR-7164: BBoxFieldType defaults sub fields to not-stored
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1662355 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
08266a72ed
commit
47662fff60
|
@ -117,6 +117,8 @@ New Features
|
||||||
|
|
||||||
* SOLR-5507: Admin UI - Refactoring using AngularJS, first part (Upayavira via
|
* SOLR-5507: Admin UI - Refactoring using AngularJS, first part (Upayavira via
|
||||||
Erick Erickson)
|
Erick Erickson)
|
||||||
|
|
||||||
|
* SOLR-7164: BBoxFieldType defaults sub fields to not-stored (ryan)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class BBoxField extends AbstractSpatialFieldType<BBoxStrategy> implements
|
||||||
|
|
||||||
private String numberTypeName;//required
|
private String numberTypeName;//required
|
||||||
private String booleanTypeName = "boolean";
|
private String booleanTypeName = "boolean";
|
||||||
|
private boolean storeSubFields = false;
|
||||||
|
|
||||||
private IndexSchema schema;
|
private IndexSchema schema;
|
||||||
|
|
||||||
|
@ -66,6 +67,11 @@ public class BBoxField extends AbstractSpatialFieldType<BBoxStrategy> implements
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
booleanTypeName = v;
|
booleanTypeName = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v = args.remove("storeSubFields");
|
||||||
|
if (v != null) {
|
||||||
|
storeSubFields = Boolean.valueOf(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,7 +114,15 @@ public class BBoxField extends AbstractSpatialFieldType<BBoxStrategy> implements
|
||||||
// note: Registering the field is probably optional; it makes it show up in the schema browser and may have other
|
// note: Registering the field is probably optional; it makes it show up in the schema browser and may have other
|
||||||
// benefits.
|
// benefits.
|
||||||
private void register(IndexSchema schema, String name, FieldType fieldType) {
|
private void register(IndexSchema schema, String name, FieldType fieldType) {
|
||||||
SchemaField sf = new SchemaField(name, fieldType);
|
int props = fieldType.properties;
|
||||||
|
props &= ~MULTIVALUED; // must not be multivalued
|
||||||
|
if(storeSubFields) {
|
||||||
|
props |= STORED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
props &= ~STORED;
|
||||||
|
}
|
||||||
|
SchemaField sf = new SchemaField(name, fieldType, props, null);
|
||||||
schema.getFields().put(sf.getName(), sf);
|
schema.getFields().put(sf.getName(), sf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
numberType="tdouble" distanceUnits="degrees"/>
|
numberType="tdouble" distanceUnits="degrees"/>
|
||||||
|
|
||||||
<fieldType name="bbox" class="solr.BBoxField"
|
<fieldType name="bbox" class="solr.BBoxField"
|
||||||
numberType="tdoubleDV" distanceUnits="degrees"/>
|
numberType="tdoubleDV" distanceUnits="degrees" storeSubFields="false"/>
|
||||||
</types>
|
</types>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,13 @@ import com.spatial4j.core.context.SpatialContext;
|
||||||
import com.spatial4j.core.distance.DistanceUtils;
|
import com.spatial4j.core.distance.DistanceUtils;
|
||||||
import com.spatial4j.core.shape.Point;
|
import com.spatial4j.core.shape.Point;
|
||||||
import com.spatial4j.core.shape.Rectangle;
|
import com.spatial4j.core.shape.Rectangle;
|
||||||
|
|
||||||
|
import org.apache.lucene.spatial.bbox.BBoxStrategy;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
|
import org.apache.solr.schema.BBoxField;
|
||||||
|
import org.apache.solr.schema.IndexSchema;
|
||||||
|
import org.apache.solr.schema.SchemaField;
|
||||||
import org.apache.solr.util.SpatialUtils;
|
import org.apache.solr.util.SpatialUtils;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -366,4 +371,16 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 {
|
||||||
SolrException.ErrorCode.BAD_REQUEST);
|
SolrException.ErrorCode.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSpatialConfig() throws Exception {
|
||||||
|
IndexSchema schema = h.getCoreInc().getLatestSchema();
|
||||||
|
|
||||||
|
// BBox Config
|
||||||
|
// Make sure the subfields are not stored
|
||||||
|
SchemaField sub = schema.getField("bbox"+BBoxStrategy.SUFFIX_MINX);
|
||||||
|
assertFalse(sub.stored());
|
||||||
|
assertFalse(sub.multiValued());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue