我想索引和搜索两个不同的实体.
文件名:db-data-config.xml
<dataConfig> <dataSource name="myindex" driver="com.microsoft.sqlserver.jdbc.sqlServerDriver" url="jdbc:sqlserver://test-pc:1433;DatabaseName=SampleDB" user="username" password="password" /> <document> <entity name="Employees" query="select * from employee" transformer="TemplateTransformer" dataSource="myindex"> <field column="id" name="singlekey" /> <field column="eId" name="eid" /> <field column="eName" name="ename" /> <field column="entity" template="Employee" name="entity" /> </entity> <entity name="Products" query="select * from products" transformer="TemplateTransformer" dataSource="myindex"> <field column="id" name="singlekey" /> <field column="pId" name="pid" /> <field column="pName" name="pname" /> <field column="entity" template="Product" name="entity" /> </entity> </document>
文件名:schema.xml
<?xml version="1.0" encoding="UTF-8" ?> <schema name="db" version="1.1"> <types> <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/> </types> <fields> <!-- Employee --> <field name="eid" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <field name="ename" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <!-- Products --> <field name="pid" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <field name="pname" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <!--Common fields--> <field name="entity" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <field name="singlekey" type="string" indexed="true" stored="true" required="true" multiValued="false" /> </fields> <uniqueKey>singlekey</uniqueKey> </schema>
如下链接:
https://stackoverflow.com/questions/5636209/how-to-index-and-search-two-different-tables-which-are-in-same-datasource-using
这个问题可以通过使用静态字段(添加新字段 – 这里是’实体’)来解决.
但我看到在添加第二个实体后,它甚至无法索引数据.
如下图所示.
它能够从sql server数据库中获取10条记录,但索引0行,意味着没有完成索引过程.
所以即使不能搜索.
有谁能解决这个问题?
提前致谢.