2個不同的表沒有關係
數據-config.xml中:
<document>
<entity name="topic" transformer="TemplateTransformer" pk="topic_id" query="select topic_id,topic_title,creation_date,updation_date,vote_count,.....">
<field column=" doc_id " template="TOPIC_${topic.topic_id} " />
<field column="doc_type " template="TOPIC " />
</entity>
<entity name="product " transformer="TemplateTransformer " pk="product_id " query="SELECT product_id,..... ">
<field column="doc_id " template="PRODUCT_${product.product_id} " />
<field column="doc_type " template="PRODUCT " />
<field column="product_supplier_id " name="product_supplier_id " />
<field column="supplier_product_code " name="supplier_product_code " />
<field column="product_display_name " name="product_display_name " />
</entity>
</document>
架構。XML:
<schema>
. . .
<fields>
<field name="doc_id" type="string" />
<field name="doc_type" type="string" />
<field name="catchall" type="string" stored="false" omitNorms="true" multiValued="true" />
<field name="topic_title" type="text_general" />. . . .
</fields>
<uniqueKey>doc_id</uniqueKey>
<copyField source="*" dest="catchall" />
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>catchall</defaultSearchField>
</schema>
更多信息 - http://www.lucidimagination.com/blog/2011/02/12/solr-powered-isfdb-part-4/
沒有上述領域應要求或建立索引時
可能會產生問題
你可以在瀏覽器查詢像http://localhost:8080/solr/select/?q=*:*&fq=doc_type:PRODUCT
當我試圖指數兩個Entity這種風格,它甚至沒有編入索引的實體。 – 2014-03-20 10:33:06
請參考以下鏈接:http://stackoverflow.com/questions/22534121/how-to-index-and-search-two-different-tables-which-are-in-same-datasource-using – 2014-03-20 13:20:30