I'm trying to run a block join query to pull child documents but I'm getting a "Parent query yields document which is not matched by parents filter" error. I'm using Solr 5.5
My schema looks like this:
<field name="url" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="name" type="text_en" indexed="true" stored="true" required="true" multiValued="false" />
<field name="content_type" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<uniqueKey>url</uniqueKey>
Insert statement looks like this:
{
"url": "http://www.test.com/index.html",
"name": "parent product",
"content_type": "parentDocument",
"_childDocuments_": [
{
"url": "http://www.test.com/index2.html",
"name": "child product",
"content_type": "childDocument"
},
{
"url": "http://www.test.com/index3.html",
"name": "child product 2",
"content_type": "childDocument"
}
]
}
Running a standard *:*
query in the console pulls back the 3 documents and shows the children belong to their parent:
{
"docs": [
{
"url": "http://www.test.com/index2.html",
"name": "child product",
"content_type": "childDocument",
"_root_": "http://www.test.com/index.html"
},
{
"url": "http://www.test.com/index3.html",
"name": "child product 2",
"content_type": "childDocument",
"_root_": "http://www.test.com/index.html"
},
{
"url": "http://www.test.com/index.html",
"name": "test product",
"content_type": "parentDocument",
"_version_": 1541193313504198700,
"_root_": "http://www.test.com/index.html"
}
]
}
However If I run q={!child of="content_type:parentDocument"}
I get the parent document which I would not expect given the "child of" statement:
{
"responseHeader": {
"status": 0,
"QTime": 0,
"params": {
"q": "{!child of=\"content_type:parentDocument\"}",
"indent": "true",
"wt": "json"
}
},
"response": {
"numFound": 1,
"start": 0,
"docs": [
{
"url": "http://www.test.com/index.html",
"name": "test product",
"content_type": "parentDocument",
"_version_": 1541193313504198656,
"_root_": "http://www.test.com/index.html"
}
]
}
}
But if I add any sort of query I get an error eg
q={!child of="content_type:parentDocument"}name:product
or even
q={!child of="content_type:parentDocument"}name:*
"Parent query yields document which is not matched by parents filter, docID=0"
So as I now understand it the query cannot return child documents. It's almost like a query and a filter. The query ie name:*
could match parent and child documents which is not allowed. I added an additional filter ie +name:product +content_type:parentDocument
to restrict results to only parents. I then added the {!child of="content_type:parentDocument"}
to get the children of these parents so I now have:
{!child of="content_type:parentDocument"}+name:product +content_type:parentDocument
and this works as expected.
Similarly the inverse would be:
{!parent which="content_type:parentDocument"}+name:product +content_type:childDocument
To get the parents of children with name:product
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.