indexingsolrlucenedih

Solr: Indexing nested Documents via DIH


I want to index my document from MySql to Solr via DIH. I have a table structure like this

and other associations.

I want to index this in a nested document structure but unable to find any resource via which it can be done using DIH.

Resources refered:

Please suggest a way to index it through DIH


Solution

  • This feature has been implemented by SOLR-5147 and should be available for Solr 5.1+

    Here is a sample configuration taken from the original Jira ticket.

    <dataConfig>
      <dataSource type="JdbcDataSource" />
      <document>
        <entity name="PARENT" query="select * from PARENT">
          <field column="id" />
          <field column="desc" />
          <field column="type_s" />
          <entity child="true" name="CHILD" query="select * from CHILD where parent_id='${PARENT.id}'">
            <field column="id" />
            <field column="desc" />
            <field column="type_s" />
          </entity>
        </entity>
      </document>
    </dataConfig>
    

    note the child="true" is required for child entities.