目前,我按照这里所述评估了Block Join Children Query Parser 。
因此我创建了以下集合:
Therefore I have created the following collection:
curl "localhost:8983/solr/admin/collections?action=CREATE&name=nestedPerson&numShards=6"`然后我插入了这两个文件:
Then I have inserted these two documents:
curl 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
发布评论