简体   繁体   English

在Solr中处理多个实体

[英]Handling multiple entities in Solr

Eventhough I am new to SOLR I was able to successfully index a single table in a very short span of time. 尽管我是SOLR的新手,但我能够在很短的时间内成功索引单个表。 Now we have a requirement where the search needs to happen on multiple tables (mutiple table indexes) at the same time. 现在我们有一个要求,即需要同时在多个表(多表索引)上进行搜索。

I couldnt figure out a way to index more than one table in SOLR and search on that indexed data. 我无法找到一种方法来索引SOLR中的多个表并搜索该索引数据。 I tried using the below data config format but its just indexing either of the 2 tables (and not both the tables). 我尝试使用下面的数据配置格式,但它只是索引2个表中的任何一个(而不是两个表)。

DB-config.xml DB-config.xml中

 <dataConfig>
 <dataSource driver="com.metamatrix.jdbc.MMDriver" url="jdbc:....." />
 <document name="doc">
 <entity name="table1"
  query="select * from table1">
 <field column="ID" name="ElementID" />
 <field column="Name" name="ElementName" />
 <field column="ElementType" name="ElementType" />
 <field column="RepId" name="ElementRepId" />
</entity>

<entity name="table2"
query="select * from table2">
<field column="id" name="ElementPropertyID" />
<field column="Name" name="ElementPropertyName" />
<field column="DataType" name="ElementPropertyDataType" />
<field column="RepId" name="ElementPropertyRepId" />

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

Schema.xml

<fields>

<field name="ElementID" type="string" indexed="true"
stored="true" />
<field name="ElementName" type="string" indexed="true"
stored="true" />
<field name="ElementType" type="string" indexed="true"
stored="true" />
<field name="ElementRepId" type="string" indexed="true"
 stored="true" />

<field name="ElementPropertyID" type="string" indexed="true"
 stored="true" />
<field name="ElementPropertyName" type="string" indexed="true"
 stored="true" />
<field name="ElementPropertyDataType" type="string"
 indexed="true" stored="true" />
<field name="ElementPropertyRepId" type="string" indexed="true"
 stored="true" />


 <dynamicField name="*" type="ignored" />
 </fields>

 <uniqueKey>ElementPropertyID</uniqueKey>

Can anyone help me out with a solution / pointers to the solution. 任何人都可以帮我解决问题的解决方案/指针。

I think this is because you have 2 separate entities. 我想这是因为你有两个独立的实体。 Is there any relation between between table1 and table2..? table1和table2之间是否有任何关系? If yes then make it a single query with joins that should solve your problem. 如果是,那么使用可以解决问题的连接进行单个查询。

For more information on the DataImportHandler please refer the below link. 有关DataImportHandler的更多信息,请参阅以下链接。 http://wiki.apache.org/solr/DataImportHandler#Oracle_Example http://wiki.apache.org/solr/DataImportHandler#Oracle_Example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM