jbampton commented on a change in pull request #2122: URL: https://github.com/apache/lucene-solr/pull/2122#discussion_r543500974
########## File path: solr/core/src/test/org/apache/solr/rest/schema/TestBulkSchemaAPI.java ########## @@ -773,6 +773,108 @@ public void testCopyFieldRules() throws Exception { assertTrue("'bleh_s' copyField rule exists in the schema", l.isEmpty()); } + @SuppressWarnings({"rawtypes"}) + public void testCopyFieldWithReplace() throws Exception { + RestTestHarness harness = restTestHarness; + String newFieldName = "test_solr_14950"; + + // add-field-type + String addFieldTypeAnalyzer = "{\n" + + "'add-field-type' : {" + + " 'name' : 'myNewTextField',\n" + + " 'class':'solr.TextField',\n" + Review comment: ```suggestion " 'class' : 'solr.TextField',\n" + ``` ########## File path: solr/core/src/test/org/apache/solr/rest/schema/TestBulkSchemaAPI.java ########## @@ -773,6 +773,108 @@ public void testCopyFieldRules() throws Exception { assertTrue("'bleh_s' copyField rule exists in the schema", l.isEmpty()); } + @SuppressWarnings({"rawtypes"}) + public void testCopyFieldWithReplace() throws Exception { + RestTestHarness harness = restTestHarness; + String newFieldName = "test_solr_14950"; + + // add-field-type + String addFieldTypeAnalyzer = "{\n" + + "'add-field-type' : {" + + " 'name' : 'myNewTextField',\n" + + " 'class':'solr.TextField',\n" + + " 'analyzer' : {\n" + + " 'charFilters' : [{\n" + + " 'name':'patternReplace',\n" + + " 'replacement':'$1$1',\n" + + " 'pattern':'([a-zA-Z])\\\\\\\\1+'\n" + + " }],\n" + + " 'tokenizer' : { 'name':'whitespace' },\n" + + " 'filters' : [{ 'name':'asciiFolding' }]\n" + + " }\n"+ + "}}"; + + String response = restTestHarness.post("/schema", json(addFieldTypeAnalyzer)); + Map map = (Map) fromJSONString(response); + assertNull(response, map.get("error")); + map = getObj(harness, "myNewTextField", "fieldTypes"); + assertNotNull("'myNewTextField' field type does not exist in the schema", map); + + // add-field + String payload = "{\n" + + " 'add-field' : {\n" + + " 'name':'" + newFieldName + "',\n" + + " 'type':'myNewTextField',\n" + + " 'stored':true,\n" + + " 'indexed':true\n" + + " }\n" + + " }"; + + response = harness.post("/schema", json(payload)); + + map = (Map) fromJSONString(response); + assertNull(response, map.get("error")); + + Map m = getObj(harness, newFieldName, "fields"); + assertNotNull("'"+ newFieldName + "' field does not exist in the schema", m); + + // add copy-field with explicit source and destination + List l = getSourceCopyFields(harness, "bleh_s"); + assertTrue("'bleh_s' copyField rule exists in the schema", l.isEmpty()); + + payload = "{\n" + + " 'add-copy-field' : {\n" + + " 'source' :'bleh_s',\n" + + " 'dest':'"+ newFieldName + "'\n" + + " }\n" + + " }\n"; + response = harness.post("/schema", json(payload)); + + map = (Map) fromJSONString(response); + assertNull(response, map.get("error")); + + l = getSourceCopyFields(harness, "bleh_s"); + assertFalse("'bleh_s' copyField rule doesn't exist", l.isEmpty()); + assertEquals("bleh_s", ((Map)l.get(0)).get("source")); + assertEquals(newFieldName, ((Map)l.get(0)).get("dest")); + + // replace-field-type + String replaceFieldTypeAnalyzer = "{\n" + + "'replace-field-type' : {" + + " 'name' : 'myNewTextField',\n" + + " 'class':'solr.TextField',\n" + Review comment: ```suggestion " 'class' : 'solr.TextField',\n" + ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org