java - Solr 。如何连接两个单独的查询

标签 java solr

我想加入两个单独的查询。并显示来自他们的信息。第一个查询是来自加拿大的公司,第二个查询是名称为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 &gt; '${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 &gt; '${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 &gt; '${dih.last_index_time}'">
            <field column="id" name="id"/>
            ....
        </entity>       
    </document>
</dataSource>

关于java - Solr 。如何连接两个单独的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14607151/

相关文章:

java - 使用 Spring MVC 和 Boot 刷新静态内容

java - java中的一键二监听

java - 无法解析符号

java - 使用 JFrame 在 Java 中加载图像

solr - 什么会导致 Lucene 索引损坏?

java - 将数据库 ID 添加到 Eclipse 组合

collections - Apache Solr - Lucene - 邮政编码半径搜索

java - Solr - 如果 stored=false,则具有默认值的字段会自行重置

solr - Solr 中是否可以突出显示非查询字段?

java - 吗啉 : How to remove everything from _attachment_body