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

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

Introduction

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

Prototype

public boolean containsField(String name) 

Source Link

Usage

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  ww  w .  j a v a 2 s.  c  o m
    }

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