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

Fix full text search

parent d9059eb7
No related branches found
No related tags found
No related merge requests found
...@@ -59,9 +59,9 @@ export const updatePaginatedResults = ({ resultClass, page, pagesize, data, spar ...@@ -59,9 +59,9 @@ export const updatePaginatedResults = ({ resultClass, page, pagesize, data, spar
type: UPDATE_PAGINATED_RESULTS, type: UPDATE_PAGINATED_RESULTS,
resultClass, page, pagesize, data, sparqlQuery resultClass, page, pagesize, data, sparqlQuery
}); });
export const updateResults = ({ resultClass, data, sparqlQuery }) => ({ export const updateResults = ({ resultClass, data, sparqlQuery, query, jenaIndex }) => ({
type: UPDATE_RESULTS, type: UPDATE_RESULTS,
resultClass, data, sparqlQuery resultClass, data, sparqlQuery, query, jenaIndex
}); });
export const sortResults = (resultClass, sortBy) => ({ export const sortResults = (resultClass, sortBy) => ({
type: SORT_RESULTS, type: SORT_RESULTS,
......
...@@ -10,6 +10,7 @@ import ChevronRightIcon from '@material-ui/icons/ChevronRight'; ...@@ -10,6 +10,7 @@ import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import CircularProgress from '@material-ui/core/CircularProgress'; import CircularProgress from '@material-ui/core/CircularProgress';
import purple from '@material-ui/core/colors/purple'; import purple from '@material-ui/core/colors/purple';
import Paper from '@material-ui/core/Paper';
import { has } from 'lodash'; import { has } from 'lodash';
const styles = () => ({ const styles = () => ({
...@@ -24,14 +25,15 @@ const styles = () => ({ ...@@ -24,14 +25,15 @@ const styles = () => ({
class MaterialTableFullTextResults extends React.Component { class MaterialTableFullTextResults extends React.Component {
render() { render() {
let resultText = this.props.data.length == 1 ? 'result' : 'results'; const results = this.props.data;
//console.log(this.props.data) let resultText = results == 1 ? 'result' : 'results';
if (this.props.fetching) { if (this.props.fetching) {
return ( return (
<div className={this.props.classes.progressContainer}> <Paper className={this.props.classes.progressContainer}>
<CircularProgress style={{ color: purple[500] }} thickness={5} /> <CircularProgress style={{ color: purple[500] }} thickness={5} />
</div> </Paper>
); );
} else { } else {
return ( return (
...@@ -71,9 +73,9 @@ class MaterialTableFullTextResults extends React.Component { ...@@ -71,9 +73,9 @@ class MaterialTableFullTextResults extends React.Component {
} }
}, },
]} ]}
data={this.props.data} data={results}
title={this.props.data.length > 1 ? title={results > 1 ?
`Search term: "${this.props.query}", ${this.props.data.length} ${resultText}` : `Search term: "${this.props.query}", ${results.length} ${resultText}` :
'' ''
} }
icons={{ icons={{
......
...@@ -295,12 +295,10 @@ let SemanticPortal = (props) => { ...@@ -295,12 +295,10 @@ let SemanticPortal = (props) => {
</Grid> </Grid>
<Grid item xs={12} md={9} className={classes.resultsContainer}> <Grid item xs={12} md={9} className={classes.resultsContainer}>
<Paper className={classes.resultsContainerPaper}> <All
<All clientSideFacetedSearch={props.clientSideFacetedSearch}
clientSideFacetedSearch={props.clientSideFacetedSearch} routeProps={routeProps}
routeProps={routeProps} />
/>
</Paper>
</Grid> </Grid>
</React.Fragment> </React.Fragment>
} }
......
...@@ -160,9 +160,10 @@ const fetchResultsClientSideEpic = (action$, state$) => action$.pipe( ...@@ -160,9 +160,10 @@ const fetchResultsClientSideEpic = (action$, state$) => action$.pipe(
return ajax.getJSON(requestUrl).pipe( return ajax.getJSON(requestUrl).pipe(
map(response => updateResults({ map(response => updateResults({
resultClass: 'all', resultClass: 'all',
jenaIndex: action.jenaIndex, data: response.data,
sparqlQuery: response.sparqlQuery,
query: action.query, query: action.query,
data: response jenaIndex: action.jenaIndex
})), })),
catchError(error => of({ catchError(error => of({
type: FETCH_RESULTS_FAILED, type: FETCH_RESULTS_FAILED,
......
...@@ -5,16 +5,14 @@ import { makeObjectList } from './SparqlObjectMapper'; ...@@ -5,16 +5,14 @@ import { makeObjectList } from './SparqlObjectMapper';
export const queryJenaIndex = async ({ export const queryJenaIndex = async ({
queryTerm, queryTerm,
latMin, resultFormat
longMin,
latMax,
longMax,
}) => { }) => {
let q = jenaQuery; let q = jenaQuery;
q = q.replace('<QUERY>', ` q = q.replace('<QUERY>', `
?id text:query ('${queryTerm.toLowerCase()}' 10000) . ?id text:query ('${queryTerm.toLowerCase()}' 2000) .
`); `);
// console.log(prefixes + q) console.log(prefixes + q)
const results = await runSelectQuery(prefixes + q, endpoint, makeObjectList); const results = await runSelectQuery(prefixes + q, endpoint, makeObjectList, resultFormat);
console.log(results)
return results; return results;
}; };
...@@ -20,13 +20,16 @@ export const jenaQuery = ` ...@@ -20,13 +20,16 @@ export const jenaQuery = `
BIND(STR(?type__prefLabel_) AS ?type__prefLabel) # ignore language tags BIND(STR(?type__prefLabel_) AS ?type__prefLabel) # ignore language tags
OPTIONAL { OPTIONAL {
?id dct:source ?source__id . ?id dct:source ?source__id .
OPTIONAL { ?source__id skos:prefLabel ?source__prefLabel_ } BIND(?source__id AS ?source__prefLabel)
BIND(COALESCE(?source__prefLabel_, ?source__id) as ?source__prefLabel)
# this used to work but now its painfully slow:
#OPTIONAL { ?source__id skos:prefLabel ?source__prefLabel_ }
#BIND(COALESCE(?source__prefLabel_, ?source__id) as ?source__prefLabel)
} }
OPTIONAL { OPTIONAL {
?id mmm-schema:data_provider_url ?dataProviderUrl ?id mmm-schema:data_provider_url ?dataProviderUrl
} }
FILTER(?type__id != frbroo:F27_Work_Conception) #FILTER(?type__id != frbroo:F27_Work_Conception)
} }
`; `;
......
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