List of usage examples for org.apache.solr.client.solrj.response.schema SchemaResponse getSchemaRepresentation
public SchemaRepresentation getSchemaRepresentation()
From source file:com.streamsets.pipeline.solr.impl.SolrTarget06.java
License:Apache License
private void getRequiredFieldNames() throws SolrServerException, IOException { SchemaRequest schemaRequest = new SchemaRequest(); SchemaResponse schemaResponse = schemaRequest.process(solrClient); SchemaRepresentation schemaRepresentation = schemaResponse.getSchemaRepresentation(); List<Map<String, Object>> fields = schemaRepresentation.getFields(); for (Map<String, Object> field : fields) { if (field.containsKey(REQUIRED) && field.get(REQUIRED) == "true") { requiredFieldNamesMap.add(field.get(REQUIRED).toString()); }// w w w. ja v a 2 s .com } }
From source file:org.apache.storm.solr.schema.builder.RestJsonSchemaBuilderV2.java
License:Apache License
@Override public void buildSchema() throws IOException { SolrClient solrClient = null;/*from ww w .j a v a2 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(); } } }