SOLR -块连接父查询解析器变化的可能性



我最近更改了我们的Solr集群的模式现在在嵌套结构中索引文档. 我索引餐厅作为父母与它的作为孩子文档。BJQ(块连接查询)父查询解析器可以方便地过滤出满足给定条件的子节点的所有父节点-

{!parent which=doc_type:restaurant}doc_type:dish AND dish_name:burger
所以上面的查询返回所有有汉堡的餐厅作为其中的一道菜。我有一个用例,我想过滤掉所有的餐厅有多个菜都在一次例如餐厅销售汉堡,薯条两者。
{!parent which=doc_type:restaurant}doc_type:dish AND (dish_name:burger OR dish_name:fries)

以上查询将返回出售汉堡的餐厅薯条或.

过滤出使用BJQ同时销售这两种产品的餐馆似乎很乏味。我如何写查询来实现这一点?

我发现一种方法使用{!bool}

q={!bool
must="{!parent which=doc_type:restaurant}(+doc_type:dish +dish_name:burger)" 
must="{!parent which=doc_type:restaurant}(+doc_type:dish +dish_name:fries)"
}

如果你想使用多值引用,请注意这在块连接的情况下不能正常工作。

使用单值引用作为解决方法

q={!bool must=$ref1 must=$ref2}
&ref1={!parent which=doc_type:restaurant}+doc_type:dish +dish_name:burger
&ref2={!parent which=doc_type:restaurant}+doc_type:dish +dish_name:fries

最新更新