List of usage examples for org.apache.solr.client.solrj.request.schema SchemaRequest SchemaRequest
public SchemaRequest()
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 . j a va 2 s. c o m*/ } }
From source file:org.apache.metron.solr.dao.SolrColumnMetadataDao.java
License:Apache License
protected List<Map<String, Object>> getIndexFields(String index) throws IOException, SolrServerException { List<Map<String, Object>> indexFields = new ArrayList<>(); // Get all the fields in use, including dynamic fields LukeRequest lukeRequest = new LukeRequest(); LukeResponse lukeResponse = lukeRequest.process(client, index); for (Entry<String, LukeResponse.FieldInfo> field : lukeResponse.getFieldInfo().entrySet()) { Map<String, Object> fieldData = new HashMap<>(); fieldData.put("name", field.getValue().getName()); fieldData.put("type", field.getValue().getType()); indexFields.add(fieldData);// w w w .j a v a 2 s .c o m } // Get all the schema fields SchemaRepresentation schemaRepresentation = new SchemaRequest().process(client, index) .getSchemaRepresentation(); indexFields.addAll(schemaRepresentation.getFields()); return indexFields; }
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(); } } }
From source file:org.springframework.data.solr.core.schema.DefaultSchemaOperations.java
License:Apache License
@Override public SchemaDefinition readSchema() { SchemaRepresentation representation = template.execute( solrClient -> new SchemaRequest().process(solrClient, collection).getSchemaRepresentation()); SchemaDefinition sd = new SchemaDefinition(collection); for (Map<String, Object> fieldValueMap : representation.getFields()) { sd.addFieldDefinition(FieldDefinition.fromMap(fieldValueMap)); }//from ww w . j a v a 2 s . c om for (Map<String, Object> fieldValueMap : representation.getCopyFields()) { CopyFieldDefinition cf = CopyFieldDefinition.fromMap(fieldValueMap); sd.addCopyField(cf); if (sd.getFieldDefinition(cf.getSource()) != null) { sd.getFieldDefinition(cf.getSource()).setCopyFields(cf.getDestination()); } } return sd; }