我想加入两个单独的查询。并显示来自他们的信息。第一个查询是来自加拿大的公司,第二个查询是名称为Incremento的公司。所以我需要运行单独的查询并连接结果信息。
我的架构是:
<entity name="firm" dataSource="jdbc" pk="id"
query="select * from firm"
deltaImportQuery="select * from firm where id='${dih.delta.id}'"
deltaQuery="select id from firm where upd_date > '${dih.last_index_time}'">
<field column="id" name="id"/>
<field column="ADDRESS" name="address"/>
<field column="EMPLOYEE" name="employee"/>
<field column="NAME" name="name"/>
<field column="VILLAGE" name="village"/>
<field column="ZIPCODE" name="zipcode"/>
<field column="PLACE" name="place"/>
<entity name="country" pk="id"
query="select country from country where id='${firm.country}'"
deltaQuery="select id from country where upd_date > '${dih.last_index_time}'"
parentDeltaQuery="select id from firm where country=${country.id}">
<field column="country" name="countryName"/>
</entity>
</entity>
如何做到这一点???
最佳答案
搜索:-
您可以使用例如
q=name:incremento&fq=location:Canada
- 仅在位于加拿大的公司中搜索名为 Incremento 的公司
fq=location:Canada&fq=name:Incremento
- 过滤位置为 CANADA 且名称为 Incremento 的公司
索引:-
您可以在 SQL 查询中使用 OR 对来自加拿大的公司和名称为 Incremento 的公司进行处理。
例如从 COUNTRY='CANADA' OR NAME='INCRMENTO' 的公司中选择 *
OR DIH 只允许标记。您可能有多个根标签。例如
<dataSource driver="..." url="..." user=".." />
<document name="companies">
<entity name="firm_canada" dataSource="jdbc" pk="id"
query="select * from firm"
deltaImportQuery="select * from firm where id='${dih.delta.id}'"
deltaQuery="select id from firm where upd_date > '${dih.last_index_time}'">
<field column="id" name="id"/>
....
</entity>
<entity name="firm_incremento" dataSource="jdbc" pk="id"
query="select * from firm where ..."
deltaImportQuery="select * from firm where id='${dih.delta.id}'"
deltaQuery="select id from firm where upd_date > '${dih.last_index_time}'">
<field column="id" name="id"/>
....
</entity>
</document>
</dataSource>
关于java - Solr 。如何连接两个单独的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14607151/