Data import in solr from multiple entity
Asked Answered
S

1

0

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>

Superscribe answered 21/10, 2011 at 7:1 Comment(3)
If data is not found, why should the tag be generated. can you add in more details ?Backstay
yes basically If data is not found then i want to generate a blank tag. is it possible?Superscribe
Basically if Tag is not genreated in xml then on attributes Mapping showing error (Field is missing).Superscribe
F
0

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.

Fiasco answered 21/10, 2011 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.