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

Add optional typecasting config for integer facets

parent 524cee62
No related branches found
No related tags found
No related merge requests found
...@@ -195,16 +195,20 @@ const generateIntegerFilter = ({ ...@@ -195,16 +195,20 @@ const generateIntegerFilter = ({
}) => { }) => {
const facetConfig = backendSearchConfig[facetClass].facets[facetID] const facetConfig = backendSearchConfig[facetClass].facets[facetID]
const { start, end } = values const { start, end } = values
const typecasting = facetConfig.typecasting
? facetConfig.typecasting
: 'BIND(xsd:integer(ROUND(?value)) as ?valueAsInteger)'
let integerFilter = '' let integerFilter = ''
if (start === '') { if (start === '') {
integerFilter = `xsd:integer(?value) <= ${end}` integerFilter = `?valueAsInteger <= ${end}`
} else if (end === '') { } else if (end === '') {
integerFilter = `xsd:integer(?value) >= ${start}` integerFilter = `?valueAsInteger >= ${start}`
} else { } else {
integerFilter = `xsd:integer(?value) >= ${start} && xsd:integer(?value) <= ${end}` integerFilter = `?valueAsInteger >= ${start} && ?valueAsInteger <= ${end}`
} }
const filterStr = ` const filterStr = `
?${filterTarget} ${facetConfig.predicate} ?value . ?${filterTarget} ${facetConfig.predicate} ?value .
${typecasting}
FILTER( FILTER(
${integerFilter} ${integerFilter}
) )
......
...@@ -128,7 +128,8 @@ export const perspective1Config = { ...@@ -128,7 +128,8 @@ export const perspective1Config = {
facetValueFilter: '', facetValueFilter: '',
labelPath: 'mmm-schema:height/crm:P90_has_value', labelPath: 'mmm-schema:height/crm:P90_has_value',
predicate: 'mmm-schema:height/crm:P90_has_value', predicate: 'mmm-schema:height/crm:P90_has_value',
type: 'integer' type: 'integer',
typecasting: 'BIND(xsd:integer(ROUND(?value)) as ?valueAsInteger)'
}, },
width: { width: {
id: 'width', id: 'width',
......
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