Solr Custom Transfomer不工作?

时间:2015-11-18 19:55:40

标签: java solr solr5

我正在尝试使用数据导入处理程序进行索引时添加少量字段来索引索引。

下面是我的data-config.xml

<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver"
                 url="jdbc:mysql://localhost:3306/db" user="*****" password="*********"/>
    <script><![CDATA[
        function addMergedPdt(row)
        {
            var m = row.get('mergedPdt');
            if(m == null)
            {
                row.put('mergedPdt',9999999999); 
            }       
            return row;
        }


            ]]></script>

    <script><![CDATA[
        function transform(row)   
        {

            if(row.get(mergedPdt) == null)
            {
                row.put('catStock', 0);
                row.put('catPxMrp',0);
                row.put('catPrice',0);
                row.put('catCount',1)
                row.put('catRating',0);
                row.put('catAval',0);
                return row;
            }
            else
            {
                row.put('catAval',1);
                return row;
            }

        }
    ]]></script>


<document>
    <entity name="product" onError="continue" transformer="script:addMergedPdt" query="select p.id, name, image, stock, lower(p.seller) as seller, brand, 
        cast(price as signed) as price, cast(pxMrp as signed) as pxMrp, mergedPdt, shipDays, url, cast(rating as signed) as rating, 
        disc(price, pxMrp) as discount, mc.node as seller_cat, oc.node as cat, substring_index(oc.node, '|', 1) as cat1, 
        substring(substring_index(oc.node, '|', 2), length(substring_index(oc.node, '|', 1)) + 2) as cat2, 
        substring(substring_index(oc.node, '|', 3), length(substring_index(oc.node, '|', 2)) + 2) as cat3  
        from _products as p, _mergedCat as mc, _ourCat as oc where active = 1 and cat_id = mc.id and ourCat = oc.id and 
        ('${dataimporter.request.full}' != 'false' OR last_visited &gt; '${dataimporter.last_index_time}') limit 10000">
    <!-- To Papulate the Catalog Data -->
    <entity name="mergedPdt" transformer="script:transform"  onError="continue" query = "SELECT mergedPdt,count(*) as catCount,cast(max(stock) as signed) as catStock,cast(max(pxMrp) as signed) as catPxMrp,cast(min(price) as signed) as catPrice,cast(avg(rating) as signed) as catRating FROM `_products` where mergedPdt = ${product.mergedPdt}"/>
 </entity>

我遇到了一些错误

org.apache.solr.handler.dataimport.DataImportHandlerException:为实体mergedPdt调用脚本时出错处理文档#10000     at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:70)     at org.apache.solr.handler.dataimport.ScriptTransformer.transformRow(ScriptTransformer.java:59)     在org.apache.solr.handler.dataimport.EntityProcessorWrapper.applyTransformer(EntityProcessorWrapper.java:198)     在org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:256)     在org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:475)     在org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:514)     在org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:414)     在org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:329)     在org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:232)     在org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:416)     在org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:480)     在org.apache.solr.handler.dataimport.DataImporter $ 1.run(DataImporter.java:461) 引起:java.lang.NoSuchMethodException:没有这样的方法:转换     at com.sun.script.javascript.RhinoScriptEngine.invoke(RhinoScriptEngine.java:286)     at com.sun.script.javascript.RhinoScriptEngine.invokeFunction(RhinoScriptEngine.java:258)     at org.apache.solr.handler.dataimport.ScriptTransformer.transformRow(ScriptTransformer.java:55)     ......还有10个

并且所有字段都被索引,不包括我尝试使用变换器添加的额外字段。 令人惊讶的是,只有一个字段“catCount”被编入索引。

您可以信任我,我对架构定义和其他配置充满信心。

任何领导都会受到高度关注?

提前致谢:)

0 个答案:

没有答案