Conversation
When searchByNotation is enabled and a concept is matched by its skos:notation, the labelpriority BIND block was missing priority 5/6 and transformConceptSearchResult() had no handler for notation matches. Add the missing BIND, SELECT/GROUP BY entries, and a result handler that populates a new matchedNotation field — parallel to the existing matchedPrefLabel — so API consumers can see why a concept matched. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
407c898 to
1f36809
Compare
|
osma
left a comment
There was a problem hiding this comment.
Thank you for the suggested enhancement and the PR to implement it.
It all looks good except for one rather minor detail: I don't like the SPARQL variable name ?nlabel because a notation is not a label. I understand this name is intended to match the style of ?alabel and ?hlabel for altLabels and hiddenLabels, respectively. In hindsight, maybe those variable names were not so clear from the start.
OTOH, the variable ?notation is already in use for returning the notation (regardless of whether it was matched) so renaming ?nlabel to ?notation is not possible either.
I suggest renaming ?nlabel to ?nmatch and then also renaming ?alabel to ?amatch and ?hlabel to ?hmatch. This needs to be done in a few different places in the code. Once this is done then all three variable names are clearer than they are currently and align well with each other.
|
Also, we would like to have PHPUnit tests for features like this. It could go into GenericSparqlTest. Though I admit that we don't have 100% coverage for search functionality, at least it would be good not to decrease it. |



Summary
Fixes #1931 — adds a
matchedNotationfield to REST API search results when a concept is found via itsskos:notation, parallel to the existingmatchedPrefLabelfor prefLabel matches.Changes in
src/model/sparql/GenericSparql.php:BIND(IF((?pri = "5" || ?pri = "6"), ?match, ?unbound) as ?nlabel)in the$labelpriorityblock?nlabelto SELECT and GROUP BY clauseselseif (isset($row->nlabel))handler setting$hit['matchedNotation']Before (notation search
query=A.1):{ "prefLabel": "Cat", "notation": "A.1" }After:
{ "prefLabel": "Cat", "notation": "A.1", "matchedNotation": "A.1" }Test plan
query=A.1→ result includesmatchedNotation: "A.1"query=A.1.1→ result includesmatchedNotation: "A.1.1"query=Cat→ nomatchedNotationfield (prefLabel match, correct)Tested against Skosmos 3.1 with Fuseki 5.4.0,
searchByNotation true,sparqlDialect "JenaText".