Example usage for org.springframework.data.solr.core.schema SchemaDefinition getCollectionName

List of usage examples for org.springframework.data.solr.core.schema SchemaDefinition getCollectionName

Introduction

In this page you can find the example usage for org.springframework.data.solr.core.schema SchemaDefinition getCollectionName.

Prototype

@Nullable
    public String getCollectionName() 

Source Link

Usage

From source file:org.springframework.data.solr.core.schema.SolrSchemaWriter.java

public void writeSchema(SchemaDefinition schemaDefinition) {

    if (isSchemaPresent(schemaDefinition.getCollectionName())) {
        updateSchema(schemaDefinition);/* w w w  .j  a  va 2s.  co m*/
        return;
    }

    createSchema(schemaDefinition);
}

From source file:org.springframework.data.solr.core.schema.SolrSchemaWriter.java

protected void updateSchema(SchemaDefinition schemaDefinition) {

    SchemaDefinition existing = loadExistingSchema(schemaDefinition.getCollectionName());

    List<FieldDefinition> fieldsToBeCreated = new ArrayList<FieldDefinition>();
    for (FieldDefinition fieldDefinition : schemaDefinition.getFields()) {
        if (!existing.containsField(fieldDefinition.getName())) {
            fieldsToBeCreated.add(fieldDefinition);
        }/*from w ww  .  ja v  a  2 s . c o  m*/
    }

    writeFieldDefinitions(fieldsToBeCreated, schemaDefinition.getCollectionName());
}