lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steffen <elvo...@gmail.com>
Subject DataImportHandler: Javascript transformer for splitting field-values
Date Wed, 19 Nov 2008 15:33:16 GMT
Hi everyone,
I'm currently working with the nightly build of Solr (solr-2008-11-17)
and trying to figure out how to transform a row-object with Javascript
to include multiple values (in a single multivalued field). When I try
something like this as a transformer:
function splitTerms(row) {
                        //each term should be duplicated into count field-values
                        //dummy-code to show the idea
                	row.put('terms',['term','term','term']);
                	return row;
}
[...]
<entity name="searchfeedback" pk="id" transformer="script:splitTerms"
query="SELECT term,count FROM termtable WHERE id=${parent.id}" />

The DataImportHandler debugger returns:
<arr>
  <str>
    sun.org.mozilla.javascript.internal.NativeArray:sun.org.mozilla.javascript.internal.NativeArray@6a4268
  </str>
</arr>
What it *should* return:
<arr>
  <str>term</str>
  <str>term</str>
  <str>term</str>
</arr>

So, what am I doing wrong? My transformer will be invoked multiple
times from a MySQL-Query and in turn has to insert multiple values to
the same field during each invocation. It should do something similar
to the RegexTransformer (field splitBy)... is that possible? Right now
I have to use a workaround that includes the term-duplication on the
database sides, which is kinda ugly if a term has to be duplicated a
lot.
Greetings,
Steffen

Mime
View raw message