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

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

Introduction

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

Prototype

public String getUniqueKey() 

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;/* w  w w  .ja  v a  2  s .co  m*/
    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();
        }
    }
}