I am working with many collections in Solr 6.3 and they can be rather generic. In some of them, I might need to do a single query on both children and parent fields, using an "OR" operator. For illustration, suppose I have the following documents indexed in Solr:
{id: doc1,
type: parent,
specs: spec1,
NESTED_DOC_KEY:[
{id:child1, childspecs:spec1, type:child},
{id:child2, childspecs:spec2, type:child},
]},
{id: doc2,
type: parent,
specs: spec2,
NESTED_DOC_KEY:[
{id:child3, childspecs:spec3, type:child},
]},
{id: doc3,
type: parent,
specs: spec3,
NESTED_DOC_KEY:[
{id:child4, childspecs:spec4, type:child},
]},
}
I need to find, for instance, all documents with specs:spec3 OR documents with one child with childspecs:spec1. So I expect to find doc1 and doc3. I tried the following query syntax, but it returns all three documents and child1:
specs:spec3 OR {!parent which="type:parent"} childspecs:spec1
Each query works separately, so I could join the results outside Solr, but I would like to know if there is a way to do this as a single query in Solr.