title: How to index and search two different tables which are in same datasource using single solr instance Or Solr Template fields not working properly
body: <p>I want to index and search two different entity.</p>
  
  <p>File name: <strong>db-data-config.xml</strong></p>
  
  <pre><code>&lt;dataConfig&gt;
      &lt;dataSource name="myindex" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://test-pc:1433;DatabaseName=SampleDB" user="username" password="password" /&gt;
      &lt;document&gt;
  
  
       &lt;entity name="Employees" query="select * from employee" transformer="TemplateTransformer" dataSource="myindex"&gt;
              &lt;field column="id" name="singlekey" /&gt;
              &lt;field column="eId" name="eid" /&gt;
              &lt;field column="eName" name="ename" /&gt;
              &lt;field column="entity" template="Employee" name="entity" /&gt;
      &lt;/entity&gt;
  
      &lt;entity name="Products" query="select * from products" transformer="TemplateTransformer" dataSource="myindex"&gt;
              &lt;field column="id" name="singlekey" /&gt;
              &lt;field column="pId" name="pid" /&gt;
              &lt;field column="pName" name="pname" /&gt;
              &lt;field column="entity" template="Product" name="entity" /&gt;
      &lt;/entity&gt;
  
  &lt;/document&gt;
  </code></pre>
  
  <p></p>
  
  <p>File name: <strong>schema.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;schema name="db" version="1.1"&gt;
    &lt;types&gt;
      &lt;fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/&gt;
   &lt;/types&gt;
   &lt;fields&gt;
  
      &lt;!-- Employee --&gt;
      &lt;field name="eid" type="string" indexed="true" stored="true" required="true" multiValued="false" /&gt; 
      &lt;field name="ename" type="string" indexed="true" stored="true" required="true" multiValued="false" /&gt; 
  
      &lt;!-- Products --&gt;
      &lt;field name="pid" type="string" indexed="true" stored="true" required="true" multiValued="false" /&gt;
      &lt;field name="pname" type="string" indexed="true" stored="true" required="true" multiValued="false" /&gt;
  
      &lt;!--Common fields--&gt;
      &lt;field name="entity" type="string" indexed="true" stored="true" required="true" multiValued="false" /&gt;
      &lt;field name="singlekey" type="string" indexed="true" stored="true" required="true" multiValued="false" /&gt;
  &lt;/fields&gt;
  &lt;uniqueKey&gt;singlekey&lt;/uniqueKey&gt;
  &lt;/schema&gt;
  </code></pre>
  
  <p><strong>As per below link:</strong><br>
  <a href="https://stackoverflow.com/questions/5636209/how-to-index-and-search-two-different-tables-which-are-in-same-datasource-using"> https://stackoverflow.com/questions/5636209/how-to-index-and-search-two-different-tables-which-are-in-same-datasource-using</a> <br>
  This problem can solve by using static field (adding new field - here its <strong>'entity'</strong>). 
  But I saw that after adding second entity, it can't even index the data.</p>
  
  <p>As per picture shown below.<img src="https://i.stack.imgur.com/qLeFq.png" alt="Multiple entity issue - Template Transformer issue"></p>
  
  <p>Its able to <strong>fetch 10 records</strong> from sql server database but <strong>index 0 rows</strong>, means no indexing process done.
  So even can't search.
  Anyone can solve this problem?
  Thanks in advance.</p>