是否可以使Solr查询跨越按公共字段值分组的多个文档?

时间:2012-10-04 11:39:48

标签: solr

是否可以在Solr索引中的多个文档中搜索共享公共字段值并让Solr将其视为一个文档?

比方说,我将一本书的每一章上传到Solr作为单独的文档,但它们共享一个共同的字段book,这是本书的标题。

<doc>
  <field name="id">book1_chap01</field>
  <field name="book">book1</field>
  <field name="text">The proof is in the pudding.</field>
</doc>
<doc>
  <field name="id">book1_chap02</field>
  <field name="book">book1</field>
  <field name="text">The concept is different than the reality.</field>
</doc>

如果您现在搜索proof AND concept,它将不返回任何内容,因为单词出现在单独的文档中。

我希望像proof AND concept这样的搜索对所有共享书籍值“book1”的文档执行,就好像它们是一个文档一样。

Solr有可能这样吗?

2 个答案:

答案 0 :(得分:2)

我相信Solr 4.0提供的Join操作可能有助于此。

以下查询适用于上述内容:

http://localhost:8080/solr4b/collection1/select?q={!join%20from=title%20to=title}text:proof%20AND%20pudding

答案 1 :(得分:0)

您可以过滤book1的结果,然后调用OR查询。这将等同于您要查找的内容。查询应该如下所示:

q=proof OR concept&fq=book:book1
相关问题