Hi,

That looks a little painful... what are you trying to achieve by storing
JSON in there? Maybe there's a simpler way to get there...

Otis
--
Performance Monitoring - http://sematext.com/spm
On Nov 1, 2012 6:16 PM, "Mishra, Shikhar" <shikhar.mis...@telcobuy.com>
wrote:

> Hi,
>
> I'm trying to store a list of JSON objects as stored value for the field
> prices (see below).
>
> I'm getting the following error from the custom transformer function (see
> the data-config file at the end) of data import handler.
>
> Error Message
>
> -------------------------------------------------------------------------------
> Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException:
> 'eval' failed with language: JavaScript and script:
> function vendorPrices(row)    {
>
>                     var wwtCost = row.get('WWT_COST');
>                     var listPrice = row.get('LIST_PRICE');
>                     var vendorName = row.get('VENDOR_NAME');
>
>                     //Below approach fails
>                     var prices = [];
>
>                     prices.push({'vendor':vendorName});
>                     prices.push({'wwtCost':wwtCost});
>                     prices.push({'listPrice':listPrice});
>
>                     row.put('prices':prices);
>
>                     //Below approach works
>                     //row.put('prices', '{' + 'vendor:' + vendorName + ',
> ' + 'wwtCost:' + wwtCost + ', ' + 'listPrice:' + listPrice + '}');
>                     return row;
>                 } Processing Document # 1
>         at
> org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:71)
>
> Data Import Handler Configuration File
> <dataConfig>
>
>         <script>
>         <![CDATA[
>                 function vendorPrices(row)    {
>
>                     var wwtCost = row.get('WWT_COST');
>                     var listPrice = row.get('LIST_PRICE');
>                     var vendorName = row.get('VENDOR_NAME');
>
>                     //Below approach fails
>                     var prices = [];
>
>                     prices.push({'vendor':vendorName});
>                     prices.push({'wwtCost':wwtCost});
>                     prices.push({'listPrice':listPrice});
>
>                     row.put('prices':prices);
>
>                     //Below approach works
>                     //row.put('prices', '{' + 'vendor:' + vendorName + ',
> ' + 'wwtCost:' + wwtCost + ', ' + 'listPrice:' + listPrice + '}');
>                     return row;
>                 }
>         ]]>
>         </script>
>
>     <dataSource driver="oracle.jdbc.driver.OracleDriver"
> url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=
> rac-scan.somr.com)(PORT=3465))(CONNECT_DATA=(SERVICE_NAME=
> ERP_GENERAL.SOMR.ORG)))" user="dummy" password="xxxxxx"/>
>     <document>
>         <entity name="item" query="select * from wwt_catalog.wwt_product
> prod, wwt_catalog.wwt_manufacturer mfg where prod.mfg_id = mfg.mfg_id and
> prod.mfg_product_number = 'CON-CBO2-B22HPF'">
>                 <field column="PRODUCT_ID" name="id" />
>             <field column="MFG_PRODUCT_NUMBER" name="name" />
>             <field column="MFG_PRODUCT_NUMBER" name="nameSort" />
>             <field column="MFG_NAME" name="manu" />
>             <field column="MFG_ITEM_NUMBER" name="alphaNameSort" />
>             <field column="DESCRIPTION" name="features" />
>             <field column="DESCRIPTION" name="description" />
>
>             <entity name="vendor_sources"
> transformer="script:vendorPrices" query="SELECT PRICE.WWT_COST,
> PRICE.LIST_PRICE, VEND.VENDOR_NAME, AVAIL.LEAD_TIME, AVAIL.QTY_AVAILABLE
> FROM wwt_catalog.wwt_product prod, wwt_catalog.wwt_product_pricing price,
> wwt_catalog.wwt_vendor vend, wwt_catalog.wwt_product_availability avail
> WHERE  PROD.PRODUCT_ID = price.product_id(+) AND price.vendor_id =
> vend.vendor_id(+) AND PRICE.PRODUCT_ID = avail.product_id(+) AND
> PRICE.VENDOR_ID = AVAIL.VENDOR_ID(+) AND prod.PRODUCT_ID =
> '${item.PRODUCT_ID}'">
>
>             </entity>
>         </entity>
>
>     </document>
> </dataConfig>
>
>
> Are there any syntactic errors in the JavaScript code above? Thanks.
>
> Shikhar
>
>
>

Reply via email to