From a9b94ec1137eaffa3fb7f9dd782e10c026bc43d9 Mon Sep 17 00:00:00 2001 From: esikkala <esko.ikkala@aalto.fi> Date: Tue, 27 Apr 2021 08:57:50 +0300 Subject: [PATCH] Full text: update query, show note --- .../facet_results/ReactVirtualizedTable.js | 7 ++++--- src/client/reducers/sampo/fullTextSearch.js | 16 ++++++++++++++-- src/client/translations/sampo/localeEN.js | 8 ++++++-- src/server/sparql/JenaQuery.js | 2 +- src/server/sparql/SparqlQueriesGeneral.js | 4 +--- .../sparql_queries/SparqlQueriesFullText.js | 10 +++++++--- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/client/components/facet_results/ReactVirtualizedTable.js b/src/client/components/facet_results/ReactVirtualizedTable.js index 1591ff7c..0f5f77e9 100644 --- a/src/client/components/facet_results/ReactVirtualizedTable.js +++ b/src/client/components/facet_results/ReactVirtualizedTable.js @@ -68,7 +68,7 @@ class MuiVirtualizedTable extends React.PureComponent { cellRenderer = ({ cellData, columnIndex }) => { const { columns /* classes, rowHeight, onRowClick */ } = this.props - const { id, valueType, makeLink, externalLink, sortValues, numberedList, minWidth } = columns[columnIndex] + const { id, valueType, makeLink, externalLink, sortValues, numberedList, minWidth, collapsedMaxWords } = columns[columnIndex] return ( <ResultTableCell columnId={id} @@ -80,7 +80,8 @@ class MuiVirtualizedTable extends React.PureComponent { sortValues={sortValues} minWidth={minWidth} container='div' - expanded + expanded={false} + collapsedMaxWords={collapsedMaxWords} /> ) }; @@ -189,7 +190,7 @@ const rootStyle = { } const tableContainer = { - width: 700, + width: 1100, height: '100%', marginLeft: 'auto', marginRight: 'auto' diff --git a/src/client/reducers/sampo/fullTextSearch.js b/src/client/reducers/sampo/fullTextSearch.js index e45cad18..d94e5af1 100644 --- a/src/client/reducers/sampo/fullTextSearch.js +++ b/src/client/reducers/sampo/fullTextSearch.js @@ -23,12 +23,22 @@ export const INITIAL_STATE = { }, { id: 'type', - valueType: 'string', + valueType: 'object', makeLink: false, externalLink: false, sortValues: false, numberedList: false, minWidth: 300 + }, + { + id: 'note', + valueType: 'string', + makeLink: false, + externalLink: false, + sortValues: false, + numberedList: false, + minWidth: 400, + collapsedMaxWords: 4 } ], fetching: false @@ -62,13 +72,15 @@ const fullTextSearch = (state = INITIAL_STATE, action) => { sortBy = action.sortBy sortDirection = 'asc' } + const sortByProperty = state.properties.find(property => property.id === sortBy) + const sortByPath = sortByProperty.valueType === 'object' ? `${sortBy}.prefLabel` : sortBy return { ...state, sortBy, sortDirection, results: orderBy( state.results, - sortBy === 'prefLabel' ? 'prefLabel.prefLabel' : sortBy, + sortByPath, sortDirection ) } diff --git a/src/client/translations/sampo/localeEN.js b/src/client/translations/sampo/localeEN.js index 81cb159d..020799ee 100644 --- a/src/client/translations/sampo/localeEN.js +++ b/src/client/translations/sampo/localeEN.js @@ -677,10 +677,14 @@ export default { label: 'Type', description: '' }, - source: { - label: 'Source', + note: { + label: 'Note', description: '' } + // source: { + // label: 'Source', + // description: '' + // } } }, manuscripts: { diff --git a/src/server/sparql/JenaQuery.js b/src/server/sparql/JenaQuery.js index 116d0398..7fd6866e 100644 --- a/src/server/sparql/JenaQuery.js +++ b/src/server/sparql/JenaQuery.js @@ -18,7 +18,7 @@ export const queryJenaIndex = async ({ endpoint = backendSearchConfig[config.perspectiveID].endpoint } const { properties } = config - q = q.replace('<QUERY>', `?id text:query ('${queryTerm.toLowerCase()}' 2000) .`) + q = q.replace('<QUERY>', `(?id ?score) text:query ('${queryTerm.toLowerCase()}' 2000) .`) q = q.replace('<RESULT_SET_PROPERTIES>', properties) const results = await runSelectQuery({ query: endpoint.prefixes + q, diff --git a/src/server/sparql/SparqlQueriesGeneral.js b/src/server/sparql/SparqlQueriesGeneral.js index a1566dba..4a8d20fd 100644 --- a/src/server/sparql/SparqlQueriesGeneral.js +++ b/src/server/sparql/SparqlQueriesGeneral.js @@ -24,13 +24,11 @@ export const jenaQuery = ` ` export const fullTextQuery = ` - SELECT ?id ?prefLabel__id ?prefLabel__prefLabel ?prefLabel__dataProviderUrl - (SAMPLE(?type_) as ?type) + SELECT * WHERE { <QUERY> <RESULT_SET_PROPERTIES> } - GROUP BY ?id ?prefLabel__id ?prefLabel__prefLabel ?prefLabel__dataProviderUrl ` export const facetResultSetQuery = ` diff --git a/src/server/sparql/sampo/sparql_queries/SparqlQueriesFullText.js b/src/server/sparql/sampo/sparql_queries/SparqlQueriesFullText.js index 04e2513b..741e0d60 100644 --- a/src/server/sparql/sampo/sparql_queries/SparqlQueriesFullText.js +++ b/src/server/sparql/sampo/sparql_queries/SparqlQueriesFullText.js @@ -1,6 +1,6 @@ export const fullTextSearchProperties = ` { - VALUES ?type_uri { + VALUES ?type__id { frbroo:F4_Manifestation_Singleton frbroo:F1_Work frbroo:F2_Expression @@ -16,8 +16,12 @@ export const fullTextSearchProperties = ` crm:E53_Place crm:E78_Collection } - ?id a ?type_uri . - ?type_uri skos:prefLabel|rdfs:label ?type_ . + ?id a ?type__id . + ?type__id skos:prefLabel|rdfs:label ?type__prefLabel . + } + UNION + { + ?id crm:P3_has_note ?note . # crm:P3_has_note has been added to text index } UNION { -- GitLab