Data import in solr from multiple entity

末鹿安然 提交于 2019-12-11 18:17:32

问题


I am trying the Data Import Handler for SQLServer Database.

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.

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

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. 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>
    
  2. if data found in Item Table but not in ReturnSolrFilter then Tag is not generated(This is Actual Problem CustomField tag not generated)

< doc>

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

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

< /doc>


回答1:


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.



来源:https://stackoverflow.com/questions/7846018/data-import-in-solr-from-multiple-entity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!