Example usage for org.apache.solr.schema SchemaField SchemaField

List of usage examples for org.apache.solr.schema SchemaField SchemaField

Introduction

In this page you can find the example usage for org.apache.solr.schema SchemaField SchemaField.

Prototype

public SchemaField(String name, FieldType type, int properties, String defaultValue) 

Source Link

Document

Create a new SchemaField with the given name and type, and with the specified properties.

Usage

From source file:lux.solr.SolrIndexConfig.java

License:Mozilla Public License

private void informField(FieldDefinition xmlField, SolrCore core) {
    Map<String, SchemaField> schemaFields = schema.getFields();
    Map<String, FieldType> fieldTypes = schema.getFieldTypes();
    String fieldName = xmlField.getName();
    if (schemaFields.containsKey(fieldName) && xmlField.getType() != Type.TOKENS) {
        // The Solr schema has a definition for this field, but it's not a TOKENS field:
        // We're only interested in TOKENS fields here; these need to install their own special field type since they wrap the
        // analyzer defined by the schema
        return;//  w w  w  .  j a va  2 s.  co m
    }
    // look up the type of this field using the mapping in this class
    FieldType fieldType = getFieldType(xmlField);
    if (!fieldTypes.containsKey(fieldType.getTypeName())) {
        // The Solr schema does not define this field type, so add it
        logger.info("{} defining fieldType: {}", core.getName(), fieldType.getTypeName());
        fieldTypes.put(fieldType.getTypeName(), fieldType);
    } else {
        fieldType = fieldTypes.get(fieldType.getTypeName());
    }
    // Add the field to the schema
    logger.info(core.getName() + " defining field: {} of type {}", fieldName, fieldType.getTypeName());
    schemaFields.put(fieldName, new SchemaField(fieldName, fieldType, xmlField.getSolrFieldProperties(), ""));
}