Solr - 具有许多子约束的块连接父查询 [英] Solr - Block join Parent query with many Children constraints
问题描述
该问题适用于以下嵌套文档:
The question is applied for the following nested documents:
<doc>
<field name="id">1</field>
<field name="title">Solr has block join support</field>
<field name="content_type">parentDocument</field>
<doc>
<field name="id">11</field>
<field name="type">comment</field>
<field name="comments">SolrCloud supports it too!</field>
</doc>
<doc>
<field name="id">12</field>
<field name="type">publisher</field>
<field name="address">England</field>
....
</doc>
</doc>
....
我的问题是,如何编写允许对多个嵌套子文档进行约束的 Block Join Parent Query?我确实尝试了以下方法,但没有奏效:
My question is, how to write the Block Join Parent Query which allows to have constraints on multiple nested children documents? I did try the following, but it did not work:
{!parent which="content_type:accommodation"}
(
(+type:comment +comments:SolrCloud) AND
(+type:publisher +address:England)
)
0 作为结果返回!
推荐答案
对于您的用例,您可以只使用多个块连接过滤器:
For your use case you can just multiple block join filters:
q=*:*&
fq={!parent which="content_type:accommodation"}(+type:comment +comments:SolrCloud)&
fq={!parent which="content_type:accommodation"}(+type:publisher +address:England)
第一个过滤器语句会找出哪些父文档有满足条件(+type:comment +comments:SolrCloud)
的子文档.
the first filter clouse will find which parent documents have a child which satisfies condition (+type:comment +comments:SolrCloud)
.
第二个过滤器子句将对满足第一个过滤器的父文档子集进行操作.它会在这个子集中找到满足条件(+type:publisher +address:England)
的父文档.
The second filter clouse will operate over subset of parent documents that satisfy the first filter. And it will find in this subset the parent documents that satisfy condition (+type:publisher +address:England)
.
这篇关于Solr - 具有许多子约束的块连接父查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!