I am following the document on data import from solr. I can connect to my local database but the configuration file is having trouble reading a foreign key. My tables are:
product
------------
id
name
continent_id
continent
------------
id
name
My data-config.xml is:
<dataConfig>
<dataSource type="JdbcDataSource" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost/my_db" user="postgres" password="postgres" readOnly="true" />
<document name="products">
<entity name="product" query="select * from product">
<field column="ID" name="id" />
<field column="NAME" name="name" />
<entity name="continent" query="select NAME from continent where id='${product.CONTINENT_ID}'">
<field column="name" name="continent" />
</entity>
</entity>
</document>
</dataConfig>
The error I am seeing is:
SEVERE: Exception while processing: product document : SolrInputDocument[{id=id(1.0)={1}, name=name(1.0)={Fancy Pants}}]:org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: select NAME from continent where id='' Processing Document # 1
It’s connecting to the database fine but cannot read the foreign key product.CONTINENT_ID. Do I need to configure the xml above differently to read and index the continent foreign key?
make sure ${product.CONTINENT_ID} is written with continent_id in exactly the same case as the table name. Solr does not always ignore the case (sometimes it does, sometimes it does not), so use the exact one just in case.