Hi!
We have documents with one level of child documents.
One use case we have is returning (or getting stats for) child documents,
filtering by field values on both the child and the parent.

This works for «must» filter on parent:
q= *:*
fq=doc_type:child
fq=child_field:child_field_value
fq={!child of=doc_type:parent}parent_field:parent_field_value

But a «must not» filter on parent returns zero documents:
fq={!child of=doc_type:parent}-parent_field:parent_field_value

Rewriting to:
fq=-{!child of=doc_type:parent}parent_field:parent_field_value
seems to work.

Should these two be equivalent?

A concrete example of a filter on parent document: enum_attr_2021:2738
(integer field)
Stepping through query parsing
«{!child of=docType:object}enum_attr_2021:2730» is parsed to
«ToChildBlockJoinQuery (+(-enum_attr_2021:[2738 TO 2738]))»

«-{!child of=docType:object}enum_attr_2021:2730» is parsed to
«-ToChildBlockJoinQuery (+enum_attr_2021:[2730 TO 2730])»


   1. SOLR-9327 <https://issues.apache.org/jira/browse/SOLR-9327> describes
   similar behaviour for graph queries.


-- 
Kind regards,
Marvin B. Lillehaug

Reply via email to