Reputation: 5067
I have been using Solr 6.2.1 with nested documents and was trying to retrieve all child documents of a specific type of parent with the Block Join Children Query Parser, however I am getting the following error:
Parent query yields document which is not matched by parents filter
My documents are similar to:
<add>
<doc>
<field name="id">1</field>
<field name="type">MYDOCTYPE</field>
<field name="isParent">true</field>
<doc>
<field name="id">1_1</field>
<field name="comments">some comments</field>
</doc>
<doc>
<field name="id">1_2</field>
<field name="comments">some more comments</field>
</doc>
</doc>
<doc>
<field name="id">2</field>
<field name="type">MYDOCTYPE</field>
<field name="isParent">true</field>
<doc>
<field name="id">2_1</field>
<field name="comments">some comments</field>
</doc>
<doc>
<field name="id">2_2</field>
<field name="comments">some more comments</field>
</doc>
</doc>
<doc>
<field name="id">3</field>
<field name="type">MYDOCTYPE</field>
</doc>
</add>
And I'm trying to query them with: q={!child of="isParent:true"}type:MYDOCTYPE
I guess the problem is that document 3 has the type MYDOCTYPE but is not a parent document, it makes sense it isn't as it doesn't have child documents.
Is there anyway to retrieve all the children documents without adding the field isParent
to document 3?
Upvotes: 1
Views: 745
Reputation: 93
It's old question, but maybe my answer help somebody.
It's right that doc with id=3 is treated as child, therefrom error occures.
Maybe we can assume that parent document is document with isParent:true or with not empty type field and with id, then query may looks like this:
q={!child of="isParent:true OR (id:* AND type:*)"}type:MYDOCTYPE
Upvotes: 1
Reputation: 5067
I found a workaround and that is to make the query:
{!child of="isParent:true"}type:"EDH/MAG"+isParent:true
this way the second part of the query only matches doc 1 and 2 and does not throw the exception.
Upvotes: 1