Repository navigation
feat(search)!: filter and facet a root document on whether a referent’s leaf has a value - #1101
Merged
Merged
Conversation
…’s leaf has a value
A lookup naming one target may declare presenceLeaves: the extraction reads each leaf one hop
from the root, the target type’s transforms run on the referents in the batch – a referent named
by IRI alone seeded with its type, through the type’s own transforms for a lookup into its own
type – and the projection writes one boolean per root document, counting referents with an IRI
only. A plain criterion on the root, { field, leaf, exists }, selects it, and each key of the
lookup’s GraphQL where is one such criterion, ANDed like sibling keys. Everything counted on one
field is served in one facet object, each part charged as a facet calculation, which lifts the
refusals of presence on a facetable field, leaves on a facetable reference, a leaf counted by
value and by presence, and one set of presence leaves per reference type.
BREAKING CHANGE: GraphQL facet objects are renamed and reshaped. The
‹Type›‹Reference›Facets and ‹Type›‹Field›Facets objects become
‹Type›‹Field›Facet, and a presence leaf’s ‹…›‹Leaf›Facets becomes
‹Type›‹Field›‹Leaf›Facet. A field whose facet also counts its presence or a
leaf is served as ‹Type›‹Field›Facet { buckets totalValues exists ‹leaf› }
instead of IRIFacet or ValueFacet; select its buckets as
facetField(limit) { buckets { … } }. A reference counting faceted or presence
leaves takes ‹Type›‹Field›Filter, with ‹Type›‹Field›Where, instead of
‹Edge›Filter or ‹Target›Filter, and ‹Edge›JoinedFilter becomes
‹Type›‹Field›JoinedFilter; variables typed with the old names stop
validating, and adding leaves to a reference later changes its filter type
the same way. In @lde/search, PhysicalFields.leafExists covers a lookup’s
presence leaves too, PresenceCriterion takes an optional leaf, and the
SearchTypeIssue reasons presence-with-facetable, presence-leaves-not-inline,
presence-leaves-with-facetable and presence-leaf-faceted are gone, replaced
by presence-leaves-on-id-only, presence-leaves-with-several-targets,
presence-leaves-with-joinable, presence-leaves-with-literal,
presence-leaf-reserved-name and presence-leaf-without-path. A target type’s
transform also receives referents seeded as <referent> rdf:type <class>.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #1090, following the revised design.
A lookup naming one target may declare
presenceLeaves, so a root document is filtered and faceted on whether a referent holds a value for that leaf:<referent> rdf:type <class>so its type’s transforms can describe it from its key; a lookup into its own type seeds through that type’s own transforms. The projection writes one boolean per root document,${reference}_${leaf}_exists, counting only referents with an IRI – the ids the lookup stores.{ field, leaf, exists }is a plain criterion on the root; each key of a lookup’s GraphQLwhereis one, ANDed like sibling keys.buckets/totalValues(capped by the field’slimit),exists, and one sub-object per leaf, each part charged as a facet calculation. A field counting only its own values keepsIRIFacet/ValueFacet. This lifts four refusals: presence on a facetable field (feat(search)!: filter and facet a field on whether it has a value #1095), leaves on a facetable reference (feat(search): facet a root document on its entries’ leaves #1049), a leaf counted by value and by presence, and one set of presence leaves per reference type (feat(search)!: filter and facet a root document on whether an entry’s leaf has a value #1099).‹Type›‹Field›Filter/‹Type›‹Field›Where. Adding leaves to a reference therefore changes its filter type.joinablelookup, a lookup reading literals as periods, anidOnlyreference, a leaf without apath, and leaves namedbuckets,totalValuesorexists. Faceting a lookup’s leaf by value stays out.ADR 42 records the decision.
Open points, for later: inline presence leaves still use a weld of one
existswhile a lookup’s use the plainleafcriterion; the combined facet object chargesbucketsandtotalValuesseparately, so it costs more than a plainIRIFacetfor the same pair.BREAKING CHANGE: GraphQL facet objects are renamed and reshaped.
‹Type›‹Reference›Facetsand‹Type›‹Field›Facetsbecome‹Type›‹Field›Facet, and a presence leaf’s‹…›‹Leaf›Facetsbecomes‹Type›‹Field›‹Leaf›Facet. A field whose facet also counts its presence or a leaf is served as‹Type›‹Field›Facet { buckets totalValues exists ‹leaf› }instead ofIRIFacetorValueFacet. A reference counting faceted or presence leaves takes‹Type›‹Field›Filter(with‹Type›‹Field›Where) instead of‹Edge›Filteror‹Target›Filter, and‹Edge›JoinedFilterbecomes‹Type›‹Field›JoinedFilter; variables typed with the old names stop validating. In@lde/search,PhysicalFields.leafExistscovers a lookup’s presence leaves,PresenceCriteriontakes an optionalleaf, and theSearchTypeIssuereasonspresence-with-facetable,presence-leaves-not-inline,presence-leaves-with-facetableandpresence-leaf-facetedare replaced bypresence-leaves-on-id-only,presence-leaves-with-several-targets,presence-leaves-with-joinable,presence-leaves-with-literal,presence-leaf-reserved-nameandpresence-leaf-without-path. A target type’s transform also receives referents seeded as<referent> rdf:type <class>.