From 068f795422991fd4afb93aef8565f9d0278a9a2b Mon Sep 17 00:00:00 2001 From: Josh Lagrimas Date: Tue, 5 Sep 2023 11:43:57 +0100 Subject: [PATCH] issue-483: add wildcard characters when searching more than 1 character in Ontologies page --- .../repository/v2/V2OntologyRepository.java | 2 +- .../src/pages/ontologies/ontologiesSlice.ts | 47 ++++++++++++++----- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/V2OntologyRepository.java b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/V2OntologyRepository.java index 41a1783ae..8bd9a61b6 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/V2OntologyRepository.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/V2OntologyRepository.java @@ -45,7 +45,7 @@ public OlsFacetedResultsPage find( query.setExactMatch(exactMatch); query.addFilter("type", "ontology", SearchType.WHOLE_FIELD); V2SearchFieldsParser.addSearchFieldsToQuery(query, searchFields); - V2SearchFieldsParser.addSearchFieldsToQuery(query, boostFields); + V2SearchFieldsParser.addBoostFieldsToQuery(query, boostFields); V2DynamicFilterParser.addDynamicFiltersToQuery(query, properties); return solrClient.searchSolrPaginated(query, pageable) diff --git a/frontend/src/pages/ontologies/ontologiesSlice.ts b/frontend/src/pages/ontologies/ontologiesSlice.ts index 542418963..99820ce5f 100644 --- a/frontend/src/pages/ontologies/ontologiesSlice.ts +++ b/frontend/src/pages/ontologies/ontologiesSlice.ts @@ -99,7 +99,11 @@ export const hideCounts = createAction("ontologies_hide_counts"); export const getOntology = createAsyncThunk( "ontologies_ontology", async ( - { ontologyId, lang, apiUrl }: { ontologyId: string; lang: string; apiUrl?: string }, + { + ontologyId, + lang, + apiUrl, + }: { ontologyId: string; lang: string; apiUrl?: string }, { rejectWithValue } ) => { const path = `api/v2/ontologies/${ontologyId}`; @@ -226,6 +230,7 @@ export const getClassInstances = createAsyncThunk( export const getOntologies = createAsyncThunk( "ontologies_ontologies", async ({ page, rowsPerPage, search }: any, { rejectWithValue }) => { + if (search.length > 1) search = "*" + search + "*"; const path = `api/v2/ontologies?page=${page}&size=${rowsPerPage}${ search ? "&search=" + search : "" }`; @@ -264,7 +269,7 @@ export const getAncestors = createAsyncThunk( entityIri, lang, showObsoleteEnabled, - apiUrl + apiUrl, }: any) => { const doubleEncodedUri = encodeURIComponent(encodeURIComponent(entityIri)); var ancestorsPage: any; @@ -272,13 +277,17 @@ export const getAncestors = createAsyncThunk( ancestorsPage = await getPaginated( `api/v2/ontologies/${ontologyId}/classes/${doubleEncodedUri}/hierarchicalAncestors?${new URLSearchParams( { size: "1000", lang, includeObsoleteEntities: showObsoleteEnabled } - )}`, undefined, apiUrl + )}`, + undefined, + apiUrl ); } else { ancestorsPage = await getPaginated( `api/v2/ontologies/${ontologyId}/${entityType}/${doubleEncodedUri}/ancestors?${new URLSearchParams( { size: "1000", lang, includeObsoleteEntities: showObsoleteEnabled } - )}`, undefined, apiUrl + )}`, + undefined, + apiUrl ); } return ancestorsPage.elements.map((obj: any) => @@ -294,7 +303,7 @@ export const getRootEntities = createAsyncThunk( preferredRoots, lang, showObsoleteEnabled, - apiUrl + apiUrl, }: any) => { if (entityType === "individuals") { const [classesWithIndividuals, orphanedIndividuals] = await Promise.all([ @@ -304,7 +313,9 @@ export const getRootEntities = createAsyncThunk( size: "1000", lang, includeObsoleteEntities: showObsoleteEnabled, - })}`, undefined, apiUrl + })}`, + undefined, + apiUrl ), getPaginated( `api/v2/ontologies/${ontologyId}/individuals?${new URLSearchParams({ @@ -312,7 +323,9 @@ export const getRootEntities = createAsyncThunk( size: "1000", lang, includeObsoleteEntities: showObsoleteEnabled, - })}`, undefined, apiUrl + })}`, + undefined, + apiUrl ), ]); return { @@ -332,7 +345,9 @@ export const getRootEntities = createAsyncThunk( size: "1000", lang, includeObsoleteEntities: showObsoleteEnabled, - })}`, undefined, apiUrl + })}`, + undefined, + apiUrl ); return { entityType, @@ -349,7 +364,9 @@ export const getRootEntities = createAsyncThunk( size: "1000", lang, includeObsoleteEntities: showObsoleteEnabled, - })}`, undefined, apiUrl + })}`, + undefined, + apiUrl ); return { entityType, @@ -383,7 +400,9 @@ export const getNodeChildren = createAsyncThunk( lang, includeObsoleteEntities: showObsoleteEnabled, } - )}`, undefined, apiUrl + )}`, + undefined, + apiUrl ); } else if (entityTypePlural === "individuals") { childrenPage = await getPaginated( @@ -393,7 +412,9 @@ export const getNodeChildren = createAsyncThunk( lang, includeObsoleteEntities: showObsoleteEnabled, } - )}`, undefined, apiUrl + )}`, + undefined, + apiUrl ); } else { childrenPage = await getPaginated( @@ -403,7 +424,9 @@ export const getNodeChildren = createAsyncThunk( lang, includeObsoleteEntities: showObsoleteEnabled, } - )}`, undefined, apiUrl + )}`, + undefined, + apiUrl ); } return {