You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Nagaraj S <na...@outlook.com> on 2020/09/08 17:32:42 UTC

Retrieving Parent and Child Documents using the Bock Join Query Technique when the Child and parent Document having the identical field

Hi Solr Team,


I am trying to retrieve the Parent Document by using the Block Join Parent Query Parser (q={!parent which=allParents}someChildren), but the filter condition i gave is having the same field in both the parent and the child document, So the Parser is throwing the  Error : "Child query must not match same docs with parent filter. Combine them as must clauses (+) to find a problem doc."

I have a requirement where, i have two fields (firstname and lastname) which are there in parent and child level.

When i pass a firstName and lastName to Solr, it should look for the firstName and lastName either in the parent level or at the child level and also it should match both  firstName and lastName at the same level (it should look for both).

I tried with BlockJoin Query and got the above error when i specify the firstName and lastName in the child filter section.

Also i tried to fetch the entire collection using the q parameter (q=*:*) and later i filtered the result using the fq (filter query), this worked to certain extent but it didn't match both the firstName and lastName strictly.

Please help me on this.

For Ex :

{
"parent": {
    "firstName": "sam",
    "lastName": "curran",
    "age": "30",
    "degree": "MBBS",
    "docType" : "parent",
    "childrens": [{
            "firstName": "Json",
            "lastName": "Roy",
            "age": "3"

        },
        {
            "firstName": "Joe",
            "lastName": "Root",
            "age": "10"

        }
    ]
}
}

TestCases :
i/p : firstName": "sam", "lastName": "curran",
o/p : return the Json including parent and all childs

i/p : firstName": "sam", "lastName": "sung",
o/p : No doc found scenario

i/p : firstName": "Json", "lastName": "Roy",
o/p : return the Json including parent and all childs

i/p : firstName": "Json", "lastName": "Root",
o/p : No doc found scenario

Thanks,

Nagaraja S