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