Note that there are some explanatory texts on larger screens.

plurals
  1. POSolr, multiple indexes
    text
    copied!<p>I want to index 2 different entities (2 tables in SQL in this case) into my Lucene index. One table containing products, another containing news items.</p> <p>To be able to use the same search method (query) to search for both products and news items, I understand they must be in the same index, so a several core setup of Solr wouldn't work - right?</p> <p>In data-config.xml I have defined 2 document types with corresponding entities.</p> <p>In schema.xml I have defined fields for products and news items as well. In my databse design (tables) my product table's unique key is called "ProductID", where as my news item's unique key is called "Id" (this is made by the CMS I'm using).</p> <p>In data-config.xml should I just map both my unique id's to the same "name". Would that be all to make this work?</p> <p>Am I following the right approach here? </p> <p>Example of what I'm thinking;</p> <p>data-config.xml</p> <pre><code>&lt;!-- Products --&gt; &lt;document name="products"&gt; &lt;entity name="product" dataSource="sqlServer" pk="ProductID" query="SELECT ProductID, ProductNumber, ProductName, FROM EcomProducts"&gt; &lt;field column="ProductID" name="**Id**"/&gt; &lt;field column="ProductNumber" name="ProductNumber"/&gt; &lt;field column="ProductName" name="ProductName"/&gt; &lt;/entity&gt; &lt;/document&gt; &lt;!-- News items ---&gt; &lt;document name="newsitems"&gt; &lt;entity name="newsitems" dataSource="sqlServer" pk="id" query="SELECT Id, NewsItemTitle, NewsItemContent, FROM ItemType_NewsItems"&gt; &lt;field column="Id" name="**Id**"/&gt; &lt;field column="NewsItemTitle" name="NewsItemTitle"/&gt; &lt;field column="NewsItemContent" name="NewsItemContent"/&gt; &lt;/entity&gt; &lt;/document&gt; </code></pre> <p>schema.xml</p> <pre><code> &lt;!-- Products ---&gt; &lt;field name="**Id**" type="text_general" indexed="true" stored="true" required="true" /&gt; &lt;field name="ProductNumber" type="text_general" indexed="true" stored="true" required="false" /&gt; &lt;field name="ProductName" type="text_general" indexed="true" stored="true" required="false" multiValued="false"/&gt; &lt;!-- Tips og fif ---&gt; &lt;field name="**Id**" type="text_general" indexed="true" stored="true" required="true" /&gt; &lt;field name="NewsItemTitle" type="text_general" indexed="true" stored="true" required="false" /&gt; &lt;field name="NewsItemContent" type="text_general" indexed="true" stored="true" required="false" /&gt; </code></pre> <p><strong>Id</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload