mirror of https://github.com/apache/lucene.git
SOLR-5119: Managed schema problems after adding fields via Schema Rest API
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1513238 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7a42fbecbd
commit
d4c20941c9
|
@ -113,6 +113,9 @@ Bug Fixes
|
|||
|
||||
* SOLR-5121: zkcli usage help for makepath doesn't match actual command.
|
||||
(Daniel Collins via Mark Miller)
|
||||
|
||||
* SOLR-5119: Managed schema problems after adding fields via Schema Rest API.
|
||||
(Nils Kübler, Steve Rowe)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
|
|
@ -389,6 +389,9 @@ public final class ManagedIndexSchema extends IndexSchema {
|
|||
newSchema.uniqueKeyField = uniqueKeyField;
|
||||
newSchema.uniqueKeyFieldName = uniqueKeyFieldName;
|
||||
newSchema.uniqueKeyFieldType = uniqueKeyFieldType;
|
||||
|
||||
// After the schema is persisted, resourceName is the same as managedSchemaResourceName
|
||||
newSchema.resourceName = managedSchemaResourceName;
|
||||
|
||||
if (includeFieldDataStructures) {
|
||||
// These need new collections, since addFields() can add members to them
|
||||
|
|
|
@ -421,4 +421,24 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
|
|||
assertNotNull(newNewSchema.getUniqueKeyField());
|
||||
assertEquals("str", newNewSchema.getUniqueKeyField().getName());
|
||||
}
|
||||
|
||||
public void testAddFieldThenReload() throws Exception {
|
||||
deleteCore();
|
||||
File managedSchemaFile = new File(tmpConfDir, "managed-schema");
|
||||
assertTrue(managedSchemaFile.delete()); // Delete managed-schema so it won't block parsing a new schema
|
||||
initCore("solrconfig-mutable-managed-schema.xml", "schema-one-field-no-dynamic-field.xml", tmpSolrHome.getPath());
|
||||
|
||||
String fieldName = "new_text_field";
|
||||
assertNull("Field '" + fieldName + "' is present in the schema",
|
||||
h.getCore().getLatestSchema().getFieldOrNull(fieldName));
|
||||
|
||||
Map<String,Object> options = new HashMap<String,Object>();
|
||||
IndexSchema oldSchema = h.getCore().getLatestSchema();
|
||||
String fieldType = "text";
|
||||
SchemaField newField = oldSchema.newField(fieldName, fieldType, options);
|
||||
IndexSchema newSchema = oldSchema.addField(newField);
|
||||
h.getCore().setLatestSchema(newSchema);
|
||||
|
||||
h.reload();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue