SOLR-1498 RegexTransformer: sourceColName version not handling multiValued fields correctly

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@823798 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2009-10-10 06:13:55 +00:00
parent a247352966
commit 57d6174c94
2 changed files with 21 additions and 1 deletions

View File

@ -100,7 +100,7 @@ public class RegexTransformer extends Transformer {
}
}
}
for (Object result : results) row.put(col, result);
row.put(col, results);
if(otherVars != null) row.putAll(otherVars);
} else {
String value = tmpVal.toString();

View File

@ -20,6 +20,8 @@ import static org.apache.solr.handler.dataimport.RegexTransformer.REGEX;
import static org.apache.solr.handler.dataimport.RegexTransformer.GROUP_NAMES;
import static org.apache.solr.handler.dataimport.RegexTransformer.REPLACE_WITH;
import static org.apache.solr.handler.dataimport.DataImporter.COLUMN;
import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTest.createMap;
import static org.apache.solr.handler.dataimport.AbstractDataImportHandlerTest.getContext;
import org.junit.Assert;
import org.junit.Test;
@ -149,6 +151,24 @@ public class TestRegexTransformer {
Assert.assertEquals("Fuel Economy range: 26 mpg Hwy, 19 mpg City", result.get("t3"));
}
@Test
public void testMultiValuedRegex(){
List<Map<String, String>> fields = new ArrayList<Map<String, String>>();
// <field column="participant" sourceColName="person" regex="(.*)" />
Map<String, String> fld = getField("participant", null, "(.*)", "person", null);
fields.add(fld);
Context context = getContext(null, null,
null, Context.FULL_DUMP, fields, null);
ArrayList<String> strings = new ArrayList<String>();
strings.add("hello");
strings.add("world");
Map<String, Object> result = new RegexTransformer().transformRow(createMap("person", strings), context);
Assert.assertEquals(strings,result.get("participant"));
}
public static List<Map<String, String>> getFields() {
List<Map<String, String>> fields = new ArrayList<Map<String, String>>();