[UI] Proposal for shui:searchQuery - #1201
Conversation
|
I have some questions about this proposal. My understanding is that you want to query something different (different nodes) compared to what the 'standard' sh:select query does. In the example it is not clear how the two queries interact.
|
|
What is the reason this cannot be expressed by the sh:select?
Is the semantics of having two queries such that both result sets are merged? No, when The sh:in, as presented in the example above, is not a valid SelectExpression. I think we need to change this in the shacl12-sparql spec, right? It is a valid SelectExpression, I carefully read the spec, I might have missed something. I do not read the normative part as blocking having more predicates with values. We are just extending the |
|
I made changes to the PR and the issue description after a call with Robert David, Summary of what changed vs. the original proposal:
|
Feature Proposal:
shui:searchQueryExtension1. Abstract & Context
In SHACL UI, a property's value nodes are typically enumerated via
sh:in, optionally computed dynamically with ash:selectexpression (including federatedSERVICEqueries), as allowed by Dynamic SHACL in SHACL 1.2.Such baseline queries resolve a full candidate set and cannot be parameterized with a user's live search input, nor take advantage of vendor-specific full-text search (FTS) extensions.
This proposal introduces
shui:searchQuery, an optional property directly on a property shape, that lets shape authors provide a dedicated SPARQLSELECTquery for resolving candidate value nodes from live, user-provided search input (e.g. in anAutoCompleteEditor). It can be used standalone, or alongsidesh:in/sh:selectas a live-search override with a defined fallback path.2. Vocabulary Definition
shui:searchQuerysh:PropertyShape— appears directly on the property shape, not nested insidesh:inxsd:string(containing a SPARQLSELECTquery string)3. Specification Rules
Rendering & Execution Behavior:
When an end user enters or changes search input for a property rendered with a widget that consumes candidate value nodes, a renderer that supports this extension MAY evaluate the query given by
shui:searchQueryto retrieve the candidate values offered to the user.Reserved Execution Variables:
The query MUST expect the following variables to be pre-bound by the renderer before evaluation:
$searchTerm: anxsd:stringliteral containing the current search input entered by the user.$uiLanguage: a language-tagged literal identifying the user's current UI language, as determined by Language Resolution.Query Structure & Constraints:
LIMITorOFFSETsolution modifier — pagination and limits remain under the exclusive control of the renderer.Interaction with
sh:in:A property shape's permissible value nodes can still be computed via
sh:in/sh:select(includingSERVICE) per Dynamic SHACL. When a property shape combinessh:inwithshui:searchQuery, a renderer that supportsshui:searchQueryevaluates it in place of thesh:in-derived query while the user is searching. A renderer that does not supportshui:searchQuery, but does support Dynamic SHACL, MAY fall back to the baselinesh:in/sh:selectquery instead.shui:searchQuerymay also be used on its own, without anysh:in.Editor Selection:
The presence of
shui:searchQueryon a property shape signals that a live search widget is appropriate, even without an explicitshui:editorstatement — it now contributes+20to theAutoCompleteEditor's selection score.Validation Scope:
shui:searchQueryis never evaluated as part of ordinary SHACL validation and MUST NOT be treated as a constraint by a validation engine. A new subsection defines an optional mechanism for implementations that additionally want to validate value nodes returned byshui:searchQuery:shui:searchQueryso its results are a subset of (or equal to) the value nodes permitted by the property shape's other constraints (sh:class,sh:node,sh:in, etc.).SERVICE-backedsh:inexpressions, this requires a validation engine supporting federated (Dynamic SHACL) validation, and the isolated check SHOULD use only thesh:inconstraint — not the shape's other constraints — since a value node retrieved viaSERVICEtypically has no local triples and would otherwise trigger spurious violations.4. Example Usage
Standalone (no
sh:inneeded):ex:TaskShape a sh:NodeShape ; sh:targetClass ex:Task ; sh:property [ sh:name "Assignee" ; sh:path ex:assignee ; sh:class ex:Person ; shui:searchQuery """ PREFIX ex: <http://example.com/> PREFIX text: <http://jena.apache.org/text#> SELECT ?value WHERE { ?value text:query ($searchTerm $uiLanguage) . ?value a ex:Person . } """ ; ] .Combined with
sh:infor federated fallback:ex:BookShape a sh:NodeShape ; sh:targetClass ex:Book ; sh:property [ sh:name "Author" ; sh:path dct:creator ; sh:in [ sh:select """ PREFIX ex: <http://example.com/> SELECT ?value WHERE { SERVICE <http://example.com/sparql> { ?value a ex:Person . } } """ ; ] ; shui:searchQuery """ PREFIX ex: <http://example.com/> PREFIX text: <http://jena.apache.org/text#> SELECT ?value WHERE { SERVICE <http://example.com/sparql> { ?value text:query ($searchTerm $uiLanguage) . ?value a ex:Person . } } """ ; ] .If the renderer doesn't support
shui:searchQuerybut does support Dynamic SHACL, it falls back to the baselinesh:in/sh:selectquery, returning allex:Personinstances.5. Implementation Notes & Scope Boundary
shui:LabelRole,shui:DepictionRole) are resolved or injected into the search query. Renderers MAY combine filtering and label retrieval into one query or perform them separately.shui:searchQueryas a standalone SPARQL contract parameterized by$searchTermand$uiLanguagekeeps execution predictable without relying on string manipulation or automatic query restructuring by renderers.shui:searchQueryresults are not checked against the shape unless an implementation opts in to the new optional validation mechanism described above.Closes #846