Hi Emlr,

I use the example of "A General TrimTransformer" in the following link:

https://wiki.apache.org/solr/DIHCustomTransformer#transformer

But instead of trim the field value, I wanted to change the table column
name to columnName_stem.
So I can use *_stem to copy all fields.  

Here is my code, but just not working. I don't what is the problem with the
code? Any ideas? Thanks!

public class RowTransformer extends Transformer  {
    public Map<String, Object> transformRow(Map<String, Object> row, Context
context) {
        List<Map&lt;String, String>> fields = ((Context)
context).getAllEntityFields();
         
        System.out.println("fields = " + fields.size());
        
        for (Map<String, String> field : fields) {
            String columnName = field.get(DataImporter.COLUMN);
            System.out.println("columnName = "    + columnName);
            // Get this field's value from the current row
            Object value = row.get(columnName);
            if (value != null && !value.toString().trim().equals("")) {
               row.put(columnName + "_stem", value.toString().trim());
               System.out.println("positive columnName = "    + columnName);
               System.out.println("positive columnValue = "    +
value.toString());
            }
        }
        return row;
    }
}



--
View this message in context: 
http://lucene.472066.n3.nabble.com/help-with-DIH-transformer-to-add-a-suffix-to-column-names-tp4292448p4292796.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to