Solr中从多个实体导入数据 [英] Data import in solr from multiple entity

查看:69
本文介绍了Solr中从多个实体导入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试SQLServer数据库的数据导入处理程序.

I am trying the Data Import Handler for SQLServer Database.

我在 solrconfig.xml 中添加了DIhandler,根据我的数据库架构创建了 data-config.xml ,并且还在 schema中添加了一个字段.xml ,这是不同的.我正在连接SQLServer数据库.

I added the DIhandler in solrconfig.xml, created a data-config.xml according to my database schema and also added a field in the schema.xml which was different. I am connecting with SQLServer database.

连接并运行 dataimport?command = full-import 后,我没有正确获取xml标记(数据).

After I connect and I run the dataimport?command=full-import I am not getting xml tag (data) properly.

在我的data-config.xml中* * ***

in my data-config.xml*****

 <document name="Product"> 
    <entity dataSource="ds-1" name="Item" pk="Item_ID"
            query="select  item.Item_ID, itemcode from item"
            deltaImportQuery="select  item.Item_ID, itemcode from item  where 
                          item.Item_ID='${dataimporter.delta.Item_ID}' "
            deltaQuery="select Item_ID from item where last_modified > 
                    '${dataimporter.last_index_time}' ">

          <entity name="ReturnSolrFilter"
              query="select Item_Id , CustomField_ID as CustomField from 
                         ReturnSolrFilter where Item_Id = '${Item.Item_ID}' "
              deltaQuery="select Item_Id , CustomField_ID as CustomField from 
                              ReturnSolrFilter where last_modified > 
                              '${dataimporter.last_index_time}' "
              parentDeltaQuery="select Item_ID from item where Item_ID = 
                              '${ReturnSolrFilter.Item_ID}' ">
         </entity>

   </entity>
  </document>

现在结果为 * ** * ***

Now the Result is *******

  1. 如果在两个表中都找到数据

  1. if data found in both Table

<doc>

  < int name="Item_ID">13773< /int>

  < str name="itemcode">15438680< /str>

    < arr name="CustomField">

        < str>31< /str>

        < str>32< /str>

    < /arr>
< /doc>

  • 如果在项目表中找到数据但在ReturnSolrFilter中找不到数据,则不会生成标记(这是未生成的实际问题CustomField标记)

    <文档>

    <int name ="Item_ID"> 13773</int>

    < int name="Item_ID">13773< /int>

    <str name ="itemcode"> 15438680</str>

    < str name="itemcode">15438680< /str>

    </doc>

    推荐答案

    我认为您需要将您的CustomField_ID包裹在isull中: isnull(Custom_ID,'')作为CustomField ,这将强制使用DataImportHandler在生成的 XML 中为 CustomField 创建一个空字段以作为 solr 文档提交.

    I think you will need to wrap your CustomField_ID with isnull: isnull(Custom_ID, '') as CustomField that should force the DataImportHandler to create an empty field for CustomField in the generated XML for submission as the solr document.

    这篇关于Solr中从多个实体导入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆