/** * Adds (or replaces) a field in the schema, set up to copy the values from the field with the locale suffix * trimmed. * * @param name the name of the field to set up * @param multiValued whether the field accepts multiple values or not * @throws SolrServerException if communicating with the Solr server failed * @throws IOException if communicating with the Solr server failed */ protected void addField(String name, boolean multiValued) throws SolrServerException, IOException { Map<String, Object> fieldDefinition = new LinkedHashMap<>(); fieldDefinition.put("name", name); fieldDefinition.put("type", "text_general_" + getTargetLocale().toString()); fieldDefinition.put("indexed", true); fieldDefinition.put("stored", true); fieldDefinition.put("multiValued", multiValued); // Add or redefine the field UpdateResponse response = new SchemaRequest.AddField(fieldDefinition).process(getClient()); if (response.getResponse().get("errors") != null) { response = new SchemaRequest.ReplaceField(fieldDefinition).process(getClient()); } }
/** * Adds (or replaces) a field in the schema, set up to copy the values from the field with the locale suffix * trimmed. * * @param name the name of the field to set up * @param multiValued whether the field accepts multiple values or not * @throws SolrServerException if communicating with the Solr server failed * @throws IOException if communicating with the Solr server failed */ protected void addField(String name, boolean multiValued) throws SolrServerException, IOException { Map<String, Object> fieldDefinition = new LinkedHashMap<>(); fieldDefinition.put("name", name); fieldDefinition.put("type", "text_general_" + getTargetLocale().toString()); fieldDefinition.put("indexed", true); fieldDefinition.put("stored", true); fieldDefinition.put("multiValued", multiValued); // Add or redefine the field UpdateResponse response = new SchemaRequest.AddField(fieldDefinition).process(getClient()); if (response.getResponse().get("errors") != null) { response = new SchemaRequest.ReplaceField(fieldDefinition).process(getClient()); } }