fix: avoid empty fields in documents

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

fix: avoid empty fields in documents

Naomi Dushay
I believe I've got a one line fix that will avoid adding fields to documents when there is no value.

In  org.solrmarc.tools.Utils.java

in the first remap() method (first argument is a String):

add this before the return statement at the end:

        if (result.length() == 0) return null;

So the method is:


    public static String remap(String fieldVal, Map<String, String> map, boolean copyEntryIfNotInMap)
    {
     StringBuffer result = new StringBuffer("");

        

        if (map.containsKey(fieldVal))
        {
         result.append(map.get(fieldVal));
        }

        

        else if (copyEntryIfNotInMap)
        {
         result.append(fieldVal);
        }
        if (result.length() == 0) return null;
        return result.toString();
    }

Enjoy!

Naomi Dushay




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech