Solr:使用Block Join Children Query Parser [英] Solr: Using the Block Join Children Query Parser

查看:124
本文介绍了Solr:使用Block Join Children Query Parser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我按照这里所述评估了Block Join Children Query Parser

因此我创建了以下集合:

Therefore I have created the following collection:

curl "http://localhost:8983/solr/admin/collections?action=CREATE&name=nestedPerson&numShards=6"`

然后我插入了这两个文件:

Then I have inserted these two documents:

curl http://localhost:8983/solr/nestedPerson/update?commitWithin=3000 -d '<add>
        <doc>
        <field name="id">p1</field>
        <field name="deceased">false</field>
        <doc>
            <field name="id">c1</field>
            <field name="firstName">Bob</field>
        </doc>
        </doc>
        <doc>
        <field name="id">p2</field>
        <field name="deceased">true</field>
        <doc>
            <field name="id">c2</field>
            <field name="firstName">Max</field>
        </doc>
        </doc>
    </add>'

现在我发出此查询:

{!child of="id:p1"}firstName:Bob

不幸的是,这导致了这个错误:

Unfortunately this results in this error:

"msg": "Parent query yields document which is not matched by parents filter, docID=0",

父查询如何(我想部分 id:p1 意味着产生一个与过滤器不匹配的文件?

How can the parent query (I guess that the part id:p1 is meant) yield a document that is not matched by the filter?

推荐答案

再看一下你再次提到的Solr Wiki 这里。请注意以下内容:

Take a look at the Solr Wiki that you refer to again here. Note the following:

此解析器的语法为:q = {!child of =< allParents>}< someParents>。参数allParents是仅匹配父文档的过滤器

在您的示例中,查询是 {!child of = ID:P1}姓:鲍勃。字段 id 用于< allParents> ,但 id 包含在父文档和子文档中。

In your example, the query is {!child of="id:p1"}firstName:Bob. The field id as used in<allParents>, but id is contained in both parent and child documents.

您需要引入一个只有父文档的字段,例如< field name =content_type> parentDocument< / field>来自wiki的。一旦所有父文档(以及仅父文档)具有此字段,您可以将查询提交为:

You need to introduce a field that only parent documents have, such as <field name="content_type">parentDocument</field> from the wiki. Once all parent documents (and only parent documents) have this field, you could submit the query as:

q = {!parent which = content_type:parentDocument} firstName:Bob

这将匹配 firstName:Bob 并归还他们的父母。以类似的方式,使用 q = {!child of =< allParents>}< someParents> 来匹配父文档并返回他们的孩子。

This would match child documents for firstName:Bob and return their parents. In a similar fashion, use q={!child of=<allParents>}<someParents> to match parent documents and return their children.

这篇关于Solr:使用Block Join Children Query Parser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆