lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject dataimporthandler and javascript transformer and default values
Date Mon, 14 Jun 2010 12:14:56 GMT

i have two questions:

1) how can i set a default value on an imported field if the
field/column is missing from a SQL query
2) i had a problem with the dataimporthandler. in one database column
(WebDst) i have a string with a comma/semicolon seperated numbers, like

	100,200; 300;400, 500

there can be a space or not. i want to have a multivalued field in the
end like

<arr name="__intern">

i thought that the javascript/script-transformer could do the trick. i
have a script like

        function dst2intern(row) {
            var webdst='';
            var count = 0;
            webdst = row.get('WebDst');
            var arr = new java.util.ArrayList();
            if (webdst) {
                // var dst = webdst.split(/[,; ] */);
                var dst = webdst.split(';');
                for (var i=0; i<dst.length; i++) {
                if (!count) {
                row.put('intern', arr);
            } else {
                row.put('intern', arr);
            return row;

in my entity-definition i have

and then i have a field __intern

 <field name="__intern" column="intern" />

i thought that this would work perfect. it seems the split only can
split on ; when comparing a single char.
the regex with 
	webdst.split(/[,; ] */);

doesn't work. i have check it in a simple html-page, there the
javascript split works with the regex.
the solution which works for me is to first use a regex transformer on

<field name="WebDst" regex="[,; ] *" replaceWith=";" column="WebDst" />
<field name="__intern" column="intern" />

and use a simple ";" split in the javascript.

i am using solr 1.4, java 1.6...

does anyone know or can tell my, why the javascript split with a regex
doesn't work?

thank you



  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message