0

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.

1 Answer 1

1

Found my problem, it is the "space" between the "{!parent which="type:parent"}" and "childspecs:spec1". It was probably interpreting as two different queries, and that is why I was getting all the parent documents and the child1.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.