I have created a custom transformer for dynamic fields but it doesn't seem to
be working correctly and I'm not sure how to debug it with a live running
solr instance. 

Here is my transformer

package org.build.com.solr;

import org.apache.solr.handler.dataimport.Context;
import org.apache.solr.handler.dataimport.Transformer;

import java.util.List;
import java.util.Map;

public class FacetsTransformer extends Transformer {
        
        public Object transformRow(Map<String, Object> row, Context context) {
                Object tf = row.get("facets");
                        if (tf != null) {
                                if (tf instanceof List) {
                                        List list = (List) tf;
                                        for (Object o : list) {
                                                String[] arr = ((String) 
o).split("=");
                                                if (arr.length == 3) 
row.put(arr[0].replaceAll("[^A-Za-z0-9]", "") +
"_" + arr[1], arr[2]);
                                        }
                                } else {
                                        String[] arr = ((String) tf).split("=");
                                        if (arr.length == 3) 
row.put(arr[0].replaceAll("[^A-Za-z0-9]", "") +
"_" + arr[1], arr[2]);
                                }
                                row.remove("facets");
                        }
                        return row;
        }
}

Seems pretty standard. Here is the data contained in the facet row:
ADA=boolean=Yes|Category=string=Kitchen Faucets|Category=string=Pullout
Kitchen Faucets|Country of Origin=string=USA|Eco
Friendly=boolean=No|Escutcheon Included=boolean=Yes|Faucet
Centers=numeric=0|Faucet Holes=numeric=1|Filtering=boolean=No|Flow Rate
(GPM)=numeric=2.20|Handle Style=string=Metal Lever|Handles
Included=boolean=Yes|Height=numeric=16.63|Hose
Length=numeric=33|Installation Type=string=Deck Mounted|Low Lead
Compliant=Boolean=Yes|MasterFinish=String=Bronze
Tones|MasterFinish=String=Chromes|MasterFinish=String=Nickel
Tones|Material=string=Metal|Max Deck Thickness=numeric=1.38|Number Of
Handles=numeric=1|Pre Rinse=boolean=No|Pullout
Spray=boolean=Yes|Sidespray=boolean=No|Soap Dispenser
Included=boolean=No|Spout Height=numeric=10.00|Spout
Reach=numeric=9.50|Spout Swivel=numeric=360|Spout Type=string=Swivel|Sub
Category=string=Pullout Spray Faucets&#x0D;
|Theme=string=Traditional / Classic|Valve Type=string=Ceramic
Disc|Width=numeric=10.5|


here is my import config file
<entity name="mainProductData"
transformer="RegexTransformer,org.build.com.solr.FacetsTransformer"
query="select facets from blah">
    <field column="facets" splitBy="|"/>
</entity>

But for some reason none of the facets are showing up in my index. The
transformer is being used because there are no class not found errors. Can
anybody lend a hand as to what might be going wrong here?


--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-Import-Handler-Custom-Transformer-not-working-tp3978746.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to