Skip to content

Add matchedNotation field to search results for notation matches#1933

Open
fvogel wants to merge 1 commit intoNatLibFi:mainfrom
fvogel:fix/notation-search-missing-bind
Open

Add matchedNotation field to search results for notation matches#1933
fvogel wants to merge 1 commit intoNatLibFi:mainfrom
fvogel:fix/notation-search-missing-bind

Conversation

@fvogel
Copy link

@fvogel fvogel commented Feb 12, 2026

Summary

Fixes #1931 — adds a matchedNotation field to REST API search results when a concept is found via its skos:notation, parallel to the existing matchedPrefLabel for prefLabel matches.

Changes in src/model/sparql/GenericSparql.php:

  • Add BIND(IF((?pri = "5" || ?pri = "6"), ?match, ?unbound) as ?nlabel) in the $labelpriority block
  • Add ?nlabel to SELECT and GROUP BY clauses
  • Add elseif (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 includes matchedNotation: "A.1"
  • query=A.1.1 → result includes matchedNotation: "A.1.1"
  • query=Cat → no matchedNotation field (prefLabel match, correct)
  • Existing PHPUnit tests pass

Tested against Skosmos 3.1 with Fuseki 5.4.0, searchByNotation true, sparqlDialect "JenaText".

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>
@fvogel fvogel force-pushed the fix/notation-search-missing-bind branch from 407c898 to 1f36809 Compare February 12, 2026 22:55
@fvogel fvogel changed the title Fix notation search matches missing from labelpriority BIND Add matchedNotation field to search results for notation matches Feb 12, 2026
@sonarqubecloud
Copy link

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.

Enhancement: add matchedNotation field to search results for notation matches

1 participant