use of org.apache.solr.legacy.BBoxStrategy in project lucene-solr by apache.
the class TestSolr4Spatial method testSpatialConfig.
@Test
public void testSpatialConfig() throws Exception {
try (SolrCore core = h.getCoreInc()) {
IndexSchema schema = core.getLatestSchema();
// BBox Config
// Make sure the subfields are not stored
SchemaField sub = schema.getField("bbox" + BBoxStrategy.SUFFIX_MINX);
assertFalse(sub.stored());
// Make sure solr field type is also not stored
BBoxField bbox = (BBoxField) schema.getField("bbox").getType();
BBoxStrategy strategy = bbox.getStrategy("bbox");
assertFalse(strategy.getFieldType().stored());
}
}
use of org.apache.solr.legacy.BBoxStrategy in project lucene-solr by apache.
the class BBoxField method newSpatialStrategy.
@Override
protected BBoxStrategy newSpatialStrategy(String fieldName) {
//if it's a dynamic field, we register the sub-fields now.
FieldType numberType = schema.getFieldTypeByName(numberTypeName);
FieldType booleanType = schema.getFieldTypeByName(booleanTypeName);
if (schema.isDynamicField(fieldName)) {
registerSubFields(schema, fieldName, numberType, booleanType);
}
//Solr's FieldType ought to expose Lucene FieldType. Instead as a hack we create a Field with a dummy value.
//dummy temp
final SchemaField solrNumField = new SchemaField("_", numberType);
org.apache.lucene.document.FieldType luceneType = (org.apache.lucene.document.FieldType) solrNumField.createField(0.0).fieldType();
luceneType.setStored(storeSubFields);
//and annoyingly this Field isn't going to have a docValues format because Solr uses a separate Field for that
if (solrNumField.hasDocValues()) {
if (luceneType instanceof LegacyFieldType) {
luceneType = new LegacyFieldType((LegacyFieldType) luceneType);
} else {
luceneType = new org.apache.lucene.document.FieldType(luceneType);
}
luceneType.setDocValuesType(DocValuesType.NUMERIC);
}
return new BBoxStrategy(ctx, fieldName, luceneType);
}
Aggregations