solrdih

Apache Solr Indexing from DIH


I have setup solr. my data-config.xml looks like below

    <dataConfig>
    <dataSource driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:/temp/example/ex" user="sa" />
    <document name="products">
     <entity name="item" query="select NAME,BSIN from items">
        <field column="NAME" name="id" />
        <field column="BSIN" name="bsin" />

        <entity name="brands" query="select brandname from brand where                 bsin='${item.BSIN}'" transformer="TemplateTransformer">
            <field name="brand" column="BRAND" />
            <field name="cname" column="namedesc" template="${item.NAME}-${brands.BRAND}" />
        </entity>

       </entity>
    </document>
   </dataConfig>

bsin and brand are multivalued fields.Now Each NAME has many BSIN and for each BSIN there is a brand name. I want index should happen in this way:

Name1-Brand1 Name1-Brand2 Name2-Brand1 etc. I am using Terms Component for autocomplete.Kindly help me achieve this.

Thanks in advance for help. Regards, Pavan


Solution

  • Try putting rootEntity="false" attribute on your outside item entity. That will indicate to DIH that the document should actually be created for each new instance of the inner brands entity.