Skip to content

feat(search)!: filter and facet a root document on whether an entry’s leaf has a value - #1099

Merged
ddeboer merged 1 commit into
mainfrom
feat/search-inline-presence
Nov 16, 2026
Merged

ddeboer merged 1 commit into
mainfrom
feat/search-inline-presence

Conversation

@ddeboer

@ddeboer ddeboer commented Nov 16, 2026

Copy link
Copy Markdown
Member

Fix #1097

An inline reference may list leaves of its entries in ref.presenceLeaves, so a root document is filtered and faceted on whether any entry holds a value for that leaf:

creativeWorks(where: { associatedMedia: { where: { thumbnailUrl: { exists: true } } } }) {
  facets { associatedMedia { thumbnailUrl { exists { value count } } } }
}
  • Storage. One boolean per root document, ${reference}_${leaf}_exists, true when any entry holds a value, false otherwise (no entries included). A per-entry boolean would count a work with entries [has, lacks] in both buckets. The name comes from physicalFields(reference).leafExists, the one source the projection, collection definition and compiler read.
  • Query. A weld of exactly one exists condition on a presence leaf selects the companion. exists among several welded conditions is refused (exists-in-weld), as is exists through a join. GraphQL rejects exists beside another key of the same entry with the rewrite.
  • Facet. ‹reference›.‹leaf›.exists, served as ‹Type›‹Reference›‹Leaf›Facets { exists: [BooleanBucket!]! } inside the reference’s facet object, beside its faceted leaves.
  • Refused for now, each lifted by Facet a root document on a leaf of the documents its lookup references #1090’s one-facet-object-per-field shape and per-reference filter inputs: presenceLeaves on a facetable reference, a leaf that is also a faceted leaf, and different presence leaves on two filterable references nesting the same Reference Type. Also refused: a leaf that is text, boolean or an inline reference, and presenceLeaves on a lookup (Facet a root document on a leaf of the documents its lookup references #1090).
  • Housekeeping. The presence ADR is renumbered from 38 to 40, since feat(search)!: search a reference by its referents’ labels #1093’s ADR also took 38; this change is ADR 41.

BREAKING CHANGE: PhysicalFields gains a required leafExists member, so code constructing a PhysicalFields must supply it. An engine adapter must declare each leaf boolean and compile a one-condition exists weld against it. A type whose inline reference declares presence leaves is reached through a join by ‹Type›JoinedWhere, and that reference by ‹RefType›JoinedFilter, without exists.


… leaf has a value

An inline reference may list presenceLeaves: the projection writes one
${reference}_${leaf}_exists boolean per root document, true when any entry
holds a value for the leaf. A weld of one exists condition selects it, the
facet ‹reference›.‹leaf›.exists counts it, and GraphQL serves it under the
leaf in the reference’s where and facets. The presence ADR is renumbered to
40, after the other ADR that took number 38.

BREAKING CHANGE: PhysicalFields gains a required leafExists member, so code
constructing a PhysicalFields must supply it. An engine adapter must declare
each leaf boolean and compile a one-condition exists weld against it.
@ddeboer
ddeboer merged commit e1999bf into main Nov 16, 2026
4 checks passed
@ddeboer
ddeboer deleted the feat/search-inline-presence branch November 16, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter and facet a root document on whether an inline entry’s leaf has a value

1 participant