Looks like it will be helpful. I'm going to give it a shot. Thanks, Otis.

Shikhar
________________________________________
From: Otis Gospodnetic [otis.gospodne...@gmail.com]
Sent: Friday, November 02, 2012 4:36 PM
To: solr-user@lucene.apache.org
Subject: Re: DataImport Handler : Transformer Function Eval Failed Error

Would http://wiki.apache.org/solr/Join do anything for you?

Otis
--
Search Analytics - http://sematext.com/search-analytics/index.html
Performance Monitoring - http://sematext.com/spm/index.html


On Fri, Nov 2, 2012 at 10:06 AM, Mishra, Shikhar <
shikhar.mis...@telcobuy.com> wrote:

> We have a scenario where the same products are available from multiple
> vendors at different prices. We want to store these prices along with the
> products in the index (product has many prices), so that we can apply
> dynamic filtering on the prices at the time of search.
>
>
> Thanks,
> Shikhar
>
> -----Original Message-----
> From: Otis Gospodnetic [mailto:otis.gospodne...@gmail.com]
> Sent: Thursday, November 01, 2012 8:13 PM
> To: solr-user@lucene.apache.org
> Subject: Re: DataImport Handler : Transformer Function Eval Failed Error
>
> 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.wrapAndT
> > hrow(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