dj_segfault
dj_segfault

Reputation: 12459

Solr querying nested documents with ChildDocTransformerFactory, get "Parent query yields document which is not matched by parents filter"

Some background:

Our data looks like this (I've removed some fields for simplicity):

{
  "id": 739063,
  "docType": "Product",
  "uuid": "P739063",
  "_childDocuments_": [
    {
      "id": 1537378,
      "price": 25.45,
      "color": "Blush",
      "docType": "Item",
      "productId": 739063,
      "uuid": "I1537378",
      "_childDocuments_": [
        {
          "id": 12799578,
          "size": "10",
          "width": "W",
          "docType": "Sku",
          "itemId": 1537378,
          "uuid": "S12799578"
        }
      ]
    }
}

The query to fetch all Products and their children nested inside them is q=docType:Product&fl=title,id,docType,[child parentFilter=docType:Product]. When I run that query, all is well, and it returns the first 10 rows. However, if I fetch more rows by adding, say &rows=500, we get the error Parent query yields document which is not matched by parents filter, docID=XXX.

When we first saw that error, we discovered our id field was not unique across document types, so we added the uuid field as mentioned above, which is. we also added in our schema.xml file, wiped the core, recreated it, and restarted Solr just to make sure it was in effect. We have double checked and are sure that the uuid fields are unique.

In all the search results for that error that I've found, the OP did not have a field that could differentiate the different document types, but as you see we do. Since both the query and the parentFilter are searching for docType:Product I don't see how either could possibly return anything but parents. We've also tried adding childFilter=docType:Item and childFilter=docType:Sku but that did not help. And I also tried using title:* for the query and parentFilter since only Products have titles.

Is there anything else we can try?

Any explanation of this?

Is it possible that it's not using uuid as the unique identifier even though it's specified in the schema.xml, and would that even cause this?

Thanks.

Upvotes: 1

Views: 1075

Answers (1)

dj_segfault
dj_segfault

Reputation: 12459

It turned out we weren't even using the schema.xml, because the solrconfig.xml was configured for managed schema. Oops.

Much of the documentation assumes you are using schemaless, and doesn't even get into the details, so I missed that.

Upvotes: 1

Related Questions