Here are the working solutions for:

3.6.1 (or lower probably)
****************************

via ScriptTransformer in data-config.xml:

                function prepareData(row) {
                        var cols = new java.util.ArrayList();
                        cols.add("spent_hours");
                        cols.add("estimated_hours");
                        cols.add("story_points");
                        cols.add("pos");
                        for (var i=0; i<cols.size(); i++) {
                                var no = row.get(cols.get(i));
                                if (no != null && no.trim().length() == 0) {
                                        row.remove(cols.get(i));
                                }
                        }
                        return row;
                }

In the XPathEntityProcessor, add the ScriptTransformer:
 transformer="script:prepareData,…"

XPATHs:

                        <field column="spent_hours"     
xpath="/issues/issue/spent_hours" />
                        <field column="estimated_hours" 
xpath="/issues/issue/estimated_hours" />
                        <field column="story_points"    
xpath="/issues/issue/story_points" />
                        <field column="pos"             
xpath="/issues/issue/position" />

All of these fields are of type tfloat, required="false". They will only get a 
value if it is not empty or null.



4.0-ALPHA
**************

No ScriptTransformer required, XPATH as above, same field type, 
required="false".

In the dataimporthandler configuration section in solrconfig.xml specify:

        <updateRequestProcessorChain name="emptyFieldChain">
                <processor class="solr.RemoveBlankFieldUpdateProcessorFactory" 
/>
                <processor class="solr.LogUpdateProcessorFactory" />
                <processor class="solr.RunUpdateProcessorFactory" />
        </updateRequestProcessorChain>

        <requestHandler name="/dataimport" 
class="org.apache.solr.handler.dataimport.DataImportHandler">
                <lst name="defaults">
                        <str name="update.chain">emptyFieldChain</str>
                        <str name="config">data-config.xml</str>
                        <str name="clean">true</str>
                        <str name="commit">true</str>
                        <str name="optimize">true</str>
                </lst>
        </requestHandler>

Reply via email to