I have a document with child documents like:

  <doc>
    <field name="id">maindoc_121</field>
    <field name="isParent">true</field>
    <field name="title>American Beauty</field>
    <doc>
        <field name="id">child_121_1</field>
        <field name="attrname">genre</field>
        <field name="attrvalue">drama</field>
    </doc>
    <doc>
        <field name="id">child_121_2</field>
        <field name="attrname">country</field>
        <field name="attrvalue">USA</field>
    </doc>
</doc>

The child documents have the same set of fields.

I can write a query that has a child which has attrname=genre and 
attrvalue=drama as

q={!parent which="isParent:true"} attrname:genre AND attrvalue:drama


But if I want to add another condition that the parent must have another child that have certain values, what do I do?

q={!parent which="isParent:true"} attrname:genre AND attrvalue:drama AND attrname:country AND attrvalue:USA

would mean a query of parent where one of the children must match. I want a parent that have two children, one is matched by one sub-query, and another is matched by another sub-query.

TK


Reply via email to