Reputation: 1807
Currently I evaluate the Block Join Children Query Parser as described here.
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>'
Now I issue this query:
{!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",
How can the parent query (I guess that the part id:p1
is meant) yield a document that is not matched by the filter?
Upvotes: 4
Views: 5336
Reputation: 2030
Take a look at the Solr Wiki that you refer to again here. Note the following:
The syntax for this parser is: q={!child of=<allParents>}<someParents>. The parameter allParents is a filter that matches only parent documents
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.
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
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.
Upvotes: 7