简体   繁体   English

Solr父子查询

[英]Solr parent-child query

I am trying to query solr documents based on criteria both in parent and a child. 我正在尝试根据父级子级中的条件查询solr文档。

Documentation: BlockJoinQueryParsers instructs to use a query like: 文档:BlockJoinQueryParsers指示使用如下查询:

q= +title:join +{!parent which="content_type:parentDocument"}comments:SolrCloud

where title is a parent's field and comments is child's. 其中title是父母的字段,而comments是孩子的字段。 A query like this works fine. 这样的查询工作正常。 However, I can not add any other condition on the child. 但是,我不能对孩子添加任何其他条件。 No matter what statement I try to put after the '}', it fails with SyntaxError. 无论我尝试在'}'之后加上什么语句,它都会因SyntaxError而失败。 For example 例如

q= +title:join +{!parent which="content_type:parentDocument"}(comments:SolrCloud AND id:4)

fails with SyntaxError. 失败,出现SyntaxError。

I think I can use a workaround by utilizing fq parameter, but I wonder if it is possible to achieve in one query. 我想可以通过利用fq参数来使用一种解决方法,但我想知道是否有可能在一个查询中实现。

PS I am using Solr 6.6, and upgrading to version 7 can be considered. PS我正在使用Solr 6.6,可以考虑升级到版本7。

You need to use local parameters , basically your query is equal to 您需要使用局部参数 ,基本上您的查询等于

q= +title:join +{!parent which="content_type:parentDocument" v='comments:SolrCloud'}

which could be rewritten even further: 可以进一步重写:

q= +title:join +{!parent which="content_type:parentDocument" v=$qq}&qq=+comments:SolrCloud +whatever:ClauseYouWant

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

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