Skip to content

Commit

Permalink
Merge pull request #493 from EBISPOT/issue-483
Browse files Browse the repository at this point in the history
issue-483: expand search when in Ontologies page
  • Loading branch information
serjoshua authored Sep 5, 2023
2 parents cdb5e02 + 068f795 commit c82d66f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public OlsFacetedResultsPage<V2Entity> 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)
Expand Down
47 changes: 35 additions & 12 deletions frontend/src/pages/ontologies/ontologiesSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down Expand Up @@ -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 : ""
}`;
Expand Down Expand Up @@ -264,21 +269,25 @@ export const getAncestors = createAsyncThunk(
entityIri,
lang,
showObsoleteEnabled,
apiUrl
apiUrl,
}: any) => {
const doubleEncodedUri = encodeURIComponent(encodeURIComponent(entityIri));
var ancestorsPage: any;
if (entityType === "classes") {
ancestorsPage = await getPaginated<any>(
`api/v2/ontologies/${ontologyId}/classes/${doubleEncodedUri}/hierarchicalAncestors?${new URLSearchParams(
{ size: "1000", lang, includeObsoleteEntities: showObsoleteEnabled }
)}`, undefined, apiUrl
)}`,
undefined,
apiUrl
);
} else {
ancestorsPage = await getPaginated<any>(
`api/v2/ontologies/${ontologyId}/${entityType}/${doubleEncodedUri}/ancestors?${new URLSearchParams(
{ size: "1000", lang, includeObsoleteEntities: showObsoleteEnabled }
)}`, undefined, apiUrl
)}`,
undefined,
apiUrl
);
}
return ancestorsPage.elements.map((obj: any) =>
Expand All @@ -294,7 +303,7 @@ export const getRootEntities = createAsyncThunk(
preferredRoots,
lang,
showObsoleteEnabled,
apiUrl
apiUrl,
}: any) => {
if (entityType === "individuals") {
const [classesWithIndividuals, orphanedIndividuals] = await Promise.all([
Expand All @@ -304,15 +313,19 @@ export const getRootEntities = createAsyncThunk(
size: "1000",
lang,
includeObsoleteEntities: showObsoleteEnabled,
})}`, undefined, apiUrl
})}`,
undefined,
apiUrl
),
getPaginated<any>(
`api/v2/ontologies/${ontologyId}/individuals?${new URLSearchParams({
hasDirectParent: "false",
size: "1000",
lang,
includeObsoleteEntities: showObsoleteEnabled,
})}`, undefined, apiUrl
})}`,
undefined,
apiUrl
),
]);
return {
Expand All @@ -332,7 +345,9 @@ export const getRootEntities = createAsyncThunk(
size: "1000",
lang,
includeObsoleteEntities: showObsoleteEnabled,
})}`, undefined, apiUrl
})}`,
undefined,
apiUrl
);
return {
entityType,
Expand All @@ -349,7 +364,9 @@ export const getRootEntities = createAsyncThunk(
size: "1000",
lang,
includeObsoleteEntities: showObsoleteEnabled,
})}`, undefined, apiUrl
})}`,
undefined,
apiUrl
);
return {
entityType,
Expand Down Expand Up @@ -383,7 +400,9 @@ export const getNodeChildren = createAsyncThunk(
lang,
includeObsoleteEntities: showObsoleteEnabled,
}
)}`, undefined, apiUrl
)}`,
undefined,
apiUrl
);
} else if (entityTypePlural === "individuals") {
childrenPage = await getPaginated<any>(
Expand All @@ -393,7 +412,9 @@ export const getNodeChildren = createAsyncThunk(
lang,
includeObsoleteEntities: showObsoleteEnabled,
}
)}`, undefined, apiUrl
)}`,
undefined,
apiUrl
);
} else {
childrenPage = await getPaginated<any>(
Expand All @@ -403,7 +424,9 @@ export const getNodeChildren = createAsyncThunk(
lang,
includeObsoleteEntities: showObsoleteEnabled,
}
)}`, undefined, apiUrl
)}`,
undefined,
apiUrl
);
}
return {
Expand Down

0 comments on commit c82d66f

Please sign in to comment.