Skip to content

Commit 407c898

Browse files
committed
Fix notation search matches missing from labelpriority BIND
Add missing BIND for notation priority (5/6) in the SPARQL query's labelpriority section, add ?nlabel to SELECT and GROUP BY, and add a handler for notation-only matches in transformConceptSearchResult(). Previously, concepts matched solely by skos:notation had no output variable bound (?plabel, ?alabel, ?hlabel all unbound), so the match type information was silently lost. Fixes #1931
1 parent b7f13f1 commit 407c898

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/model/sparql/GenericSparql.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,14 +1128,15 @@ protected function generateConceptSearchQuery($fields, $unique, $params, $showDe
11281128
BIND(IF((SUBSTR(STRBEFORE(?hit, '@'),1) != ?pri), STRLANG(STRAFTER(?hit, '@'), SUBSTR(STRBEFORE(?hit, '@'),2)), STRAFTER(?hit, '@')) AS ?match)
11291129
BIND(IF((?pri = "1" || ?pri = "2") && ?match != ?label, ?match, ?unbound) as ?plabel)
11301130
BIND(IF((?pri = "3" || ?pri = "4"), ?match, ?unbound) as ?alabel)
1131+
BIND(IF((?pri = "5" || ?pri = "6"), ?match, ?unbound) as ?nlabel)
11311132
BIND(IF((?pri = "7" || ?pri = "8"), ?match, ?unbound) as ?hlabel)
11321133
EOQ;
11331134
$innerquery = $this->generateConceptSearchQueryInner($params->getSearchTerm(), $params->getLang(), $params->getSearchLang(), $props, $unique, $filterGraph);
11341135
if ($params->getSearchTerm() === '*' || $params->getSearchTerm() === '') {
11351136
$labelpriority = '';
11361137
}
11371138
$query = <<<EOQ
1138-
SELECT DISTINCT ?s ?label ?plabel ?alabel ?hlabel ?graph ?notation (GROUP_CONCAT(DISTINCT STR(?type);separator=' ') as ?types) $extravars
1139+
SELECT DISTINCT ?s ?label ?plabel ?alabel ?nlabel ?hlabel ?graph ?notation (GROUP_CONCAT(DISTINCT STR(?type);separator=' ') as ?types) $extravars
11391140
$fcl
11401141
WHERE {
11411142
$gcl {
@@ -1152,7 +1153,7 @@ protected function generateConceptSearchQuery($fields, $unique, $params, $showDe
11521153
}
11531154
$filterGraph
11541155
}
1155-
GROUP BY ?s ?match ?label ?plabel ?alabel ?hlabel ?notation ?graph
1156+
GROUP BY ?s ?match ?label ?plabel ?alabel ?nlabel ?hlabel ?notation ?graph
11561157
ORDER BY LCASE(STR(?match)) LANG(?match) $orderextra
11571158
EOQ;
11581159
return $query;
@@ -1234,6 +1235,8 @@ private function transformConceptSearchResult($row, $vocabs, $fields)
12341235
} elseif (isset($row->alabel)) {
12351236
$hit['altLabel'] = $row->alabel->getValue();
12361237
$hit['lang'] = $row->alabel->getLang();
1238+
} elseif (isset($row->nlabel)) {
1239+
$hit['notation'] = $row->nlabel->getValue();
12371240
} elseif (isset($row->hlabel)) {
12381241
$hit['hiddenLabel'] = $row->hlabel->getValue();
12391242
$hit['lang'] = $row->hlabel->getLang();

0 commit comments

Comments
 (0)