Solr search by child document and filter on parent

15 views Asked by At

Say I have a nested documents as below

[{
    id: 'parent1',
    item_type: 'parent',
    group_id: 'g1',
    child_docs: [{
        id: 'parent1-child1',
        item_type: 'child'
        content: 'text content goes here for product abc'
    },
    {
        id: 'parent1-child2',
        item_type: 'child'
        content: 'product abc'
    }]
},
{
    id: 'parent2',
    item_type: 'parent',
    group_id: 'g2',
    child_docs: [{
        id: 'parent2-child1',
        item_type: 'child'
        content: 'another child for parent 2'
    },
    {
        id: 'parent2-child2',
        item_type: 'child'
        content: 'product cdef'
    }]
}]

I want to search by content field for term 'abc' in child document and filter by group_id in parent for group 'g1' and fetch only the child documents in result, so the result is something like,

[{
    id: 'parent1-child2',
    item_type: 'child'
    content: 'product abc'
}]

I have tried use Block join query for this and I can't seem to get it to work. How can I achieve this in with Solr?

0

There are 0 answers