Error: "Missing required field" using embedded entities in Solr's DIH Configuration File

StackOverflow https://stackoverflow.com/questions/13371630

  •  29-11-2021
  •  | 
  •  

Question

I am trying to import multiple tables from a MySQL database using Solr's Data Import Handler (DIH). The DIH does not import data from the second table, 'detail'.

My database configuration file is

<document>
    <entity name="item" pk="ListingId" query="SELECT * FROM item as item where listingid=360245270">
        <entity name="detail" pk="ListingId" query="SELECT Body FROM detail where listingid='${item.listingid}'">
            <field column="Body" name="Body" />
        </entity>
     </entity>
</document>

I monitored the MySQL query log, and the two important queries that are executed are:

SELECT * FROM item as item where listingid=360245270

SELECT Body FROM listeditemdetail where listeditemdetail.listingid=''

Clearly, the '${item.listingid}' part in the configuration file is not working as required. I have tried different spellings for the table and column names but cannot get it to work.

Était-ce utile?

La solution

(Just a Try) Try removing the primary key and using the upper case e.g. :-

<document name="items">
    <entity name="item" query="SELECT * FROM item as item where listingid=360245270">
        <field column="LISTINGID" name="listingid" />
        <entity name="detail" query="SELECT Body FROM detail where listingid='${item.LISTINGID}'">
            <field column="Body" name="Body" />
        </entity>
    </entity>
</document>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top