Example usage for org.apache.solr.client.solrj.response.schema SchemaRepresentation getName

List of usage examples for org.apache.solr.client.solrj.response.schema SchemaRepresentation getName

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.response.schema SchemaRepresentation getName.

Prototype

public String getName() 

Source Link

Usage

From source file:org.apache.storm.solr.schema.builder.RestJsonSchemaBuilderV2.java

License:Apache License

@Override
public void buildSchema() throws IOException {
    SolrClient solrClient = null;/*from w w  w .  ja  va2 s.c  om*/
    try {
        solrClient = new CloudSolrClient(solrConfig.getZkHostString());
        SchemaRequest schemaRequest = new SchemaRequest();
        logger.debug("Downloading schema for collection: {}", collection);
        SchemaResponse schemaResponse = schemaRequest.process(solrClient, collection);
        logger.debug("SchemaResponse Schema: {}", schemaResponse);
        SchemaRepresentation schemaRepresentation = schemaResponse.getSchemaRepresentation();

        schema.setName(schemaRepresentation.getName());
        schema.setVersion(Float.toString(schemaRepresentation.getVersion()));
        schema.setUniqueKey(schemaRepresentation.getUniqueKey());
        schema.setFieldTypes(getFieldTypes(schemaRepresentation));
        schema.setFields(getFields(schemaRepresentation.getFields()));
        schema.setDynamicFields(getFields(schemaRepresentation.getDynamicFields()));
        schema.setCopyFields(getCopyFields(schemaRepresentation));
    } catch (SolrServerException e) {
        logger.error("Error while getting schema for collection: {}", collection, e);
        throw new IOException("Error while getting schema for collection :" + collection, e);
    } finally {
        if (solrClient != null) {
            solrClient.close();
        }
    }
}