Search in sources :

Example 1 with BBoxStrategy

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());
    }
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) BBoxStrategy(org.apache.solr.legacy.BBoxStrategy) SolrCore(org.apache.solr.core.SolrCore) BBoxField(org.apache.solr.schema.BBoxField) IndexSchema(org.apache.solr.schema.IndexSchema) Test(org.junit.Test)

Example 2 with BBoxStrategy

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);
}
Also used : BBoxStrategy(org.apache.solr.legacy.BBoxStrategy) LegacyFieldType(org.apache.solr.legacy.LegacyFieldType) LegacyFieldType(org.apache.solr.legacy.LegacyFieldType)

Aggregations

BBoxStrategy (org.apache.solr.legacy.BBoxStrategy)2 SolrCore (org.apache.solr.core.SolrCore)1 LegacyFieldType (org.apache.solr.legacy.LegacyFieldType)1 BBoxField (org.apache.solr.schema.BBoxField)1 IndexSchema (org.apache.solr.schema.IndexSchema)1 SchemaField (org.apache.solr.schema.SchemaField)1 Test (org.junit.Test)1