Skip to content
Snippets Groups Projects
Commit 368083fa authored by esikkala's avatar esikkala
Browse files

Facet config: add optional facet label filter

parent adfebbf1
No related branches found
No related tags found
No related merge requests found
import { runSelectQuery } from './SparqlApi';
import { has } from 'lodash';
import {
endpoint,
facetValuesQuery,
......@@ -94,6 +95,11 @@ export const getFacet = async ({
q = q.replace('<SELECTED_VALUES>', selectedBlock);
q = q.replace('<SELECTED_VALUES_NO_HITS>', selectedNoHitsBlock);
q = q.replace(/<FACET_VALUE_FILTER>/g, facetConfig.facetValueFilter);
q = q.replace(/<FACET_LABEL_FILTER>/g,
has(facetConfig.facetLabelFilter)
? facetConfig.facetLabelFilter
: ''
);
q = q.replace('<PARENTS>', parentBlock);
if (facetConfig.type === 'list') {
q = q.replace('<ORDER_BY>', `ORDER BY ${sortDirection}(?${sortBy})` );
......
......@@ -80,7 +80,10 @@ export const facetValuesQuery = `
FILTER(BOUND(?id))
<FACET_VALUE_FILTER>
OPTIONAL { ?id gvp:broaderPreferred ?parent_ }
OPTIONAL { ?id skos:prefLabel|rdfs:label ?prefLabel_ }
OPTIONAL {
?id skos:prefLabel|rdfs:label ?prefLabel_
<FACET_LABEL_FILTER>
}
BIND(COALESCE(?parent_, '0') as ?parent)
BIND(COALESCE(STR(?prefLabel_), STR(?id)) AS ?prefLabel)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment