lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emir Arnautovic <emir.arnauto...@sematext.com>
Subject Re: help with DIH transformer to add a suffix to column names
Date Tue, 23 Aug 2016 07:31:49 GMT
Hi Wendy,

Why don't you simply specify column names in your query? Do you have 
that much columns that "SELECT *" is THE way to go?

For the transformer - you changed the row, but fields in context are 
still using old names - maybe try setting field names in context (if 
possible - did not look at code)

Emir

On 22.08.2016 21:47, Wendy wrote:
> 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.

-- 
Monitoring * Alerting * Anomaly Detection * Centralized Log Management
Solr & Elasticsearch Support * http://sematext.com/


Mime
View raw message