Blockjoin with Filter Query on Child Doc Result Set

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Blockjoin with Filter Query on Child Doc Result Set

Jeffrey Walraven

Is there a good way to do Solr Parent blockjoins with filter queries on
children (i.e. the results of the children query set affect the filter
on the children of the filter query)?

Solr has a convenient way of doing filter queries on the result set of
parent block joins. E.g.

|q={!parent which=doc_type:parent}content:dog &fq={!parent
which=doc_type:parent}comment:cat |

But note that this only filters the *parent* result set based on the
results of the children. The full children result set is used for the
filter both times.

To clarify, if I insert a document with child A and B

|{ "doc_type":"parent", "id":"1", __children__: [ { "id":"A" }, {
"id":"B" } ] } |

I wish to be able to search for A and filter B to get nothing in the
results, since the child doc match for id was on A (not B). Current
behavior is that the result comes back since both children are searched
in either the query or the filter query. Solr Search Example 1

To contrast, normal document filter behavior is to remove non-matching
documents from the result set. E.g. if there are two documents with id 1
& 2 and I search id:1 with a filter query of id:2 I will get no
documents back.

I know that the proper behavior can be achieved using a single query:

|q={!parent which=doc_type:parent}id:A AND id:B |

But there are certain cases where a filter query may be preferred esp.
in a situation where multiple parent block-join queries are used in the
q (or fq) value and you wish to filter over them with an fq.

If there is no current implementation for this in the current solr
project, I would appreciate guidance on if this would be reasonable to


Jeffrey Walraven

By the way, I posted this question on stackoverflow a few months back:
But I wanted to see if anybody on the solr mailing list had any
solutions/ideas on how to approach this.