private List<FieldType> getFieldTypes(SchemaRepresentation schemaRepresentation) { List<FieldType> fieldTypes = new LinkedList<>(); for (FieldTypeDefinition fd : schemaRepresentation.getFieldTypes()) { FieldType ft = new FieldType(); ft.setName((String) fd.getAttributes().get("name")); ft.setClazz((String) fd.getAttributes().get("class")); Object multiValued = fd.getAttributes().get("multiValued"); if (multiValued != null) { ft.setMultiValued((Boolean) multiValued); } fieldTypes.add(ft); } return fieldTypes; }
@Override public void buildSchema() throws IOException { SolrClient solrClient = null; 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(); } } }
public DeleteFieldType(String fieldTypeName, SolrParams q) { super(createRequestParameters(fieldTypeName), q); }
public DeleteField(String fieldName, SolrParams q) { super(createRequestParameters(fieldName), q); }
public AddField(Map<String, Object> fieldAttributes, SolrParams q) { super(createRequestParameters(fieldAttributes), q); }
public DeleteDynamicField(String fieldName, SolrParams q) { super(createRequestParameters(fieldName), q); }
public AddCopyField(String source, List<String> dest, Integer maxChars, SolrParams q) { super(createRequestParameters(source, dest, maxChars), q); }
public DeleteCopyField(String source, List<String> dest, SolrParams q) { super(createRequestParameters(source, dest), q); }
public ReplaceField(Map<String, Object> fieldAttributes, SolrParams q) { super(createRequestParameters(fieldAttributes), q); }
public ReplaceDynamicField(Map<String, Object> dynamicFieldAttributes, SolrParams q) { super(createRequestParameters(dynamicFieldAttributes), q); }
public AddDynamicField(Map<String, Object> fieldAttributes, SolrParams q) { super(createRequestParameters(fieldAttributes), q); }
public AddFieldType(FieldTypeDefinition fieldTypeDefinition, SolrParams q) { super(createRequestParameters(fieldTypeDefinition), q); }
public ReplaceFieldType(FieldTypeDefinition fieldTypeDefinition, SolrParams q) { super(createRequestParameters(fieldTypeDefinition), q); }
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); } // Get all the schema fields SchemaRepresentation schemaRepresentation = new SchemaRequest().process(client, index) .getSchemaRepresentation(); indexFields.addAll(schemaRepresentation.getFields()); return indexFields; }
public DeleteField(String fieldName, SolrParams q) { super(createRequestParameters(fieldName), q); }
public AddField(Map<String, Object> fieldAttributes, SolrParams q) { super(createRequestParameters(fieldAttributes), q); }
public DeleteDynamicField(String fieldName, SolrParams q) { super(createRequestParameters(fieldName), q); }
public AddCopyField(String source, List<String> dest, SolrParams q) { super(createRequestParameters(source, dest, null), q); }
public DeleteCopyField(String source, List<String> dest, SolrParams q) { super(createRequestParameters(source, dest), q); }
public ReplaceField(Map<String, Object> fieldAttributes, SolrParams q) { super(createRequestParameters(fieldAttributes), q); }