diff --git a/src/app/core/data/search-response-parsing.service.ts b/src/app/core/data/search-response-parsing.service.ts index bd0f63f3e98..21aaa07fd30 100644 --- a/src/app/core/data/search-response-parsing.service.ts +++ b/src/app/core/data/search-response-parsing.service.ts @@ -26,6 +26,7 @@ export class SearchResponseParsingService extends DspaceRestResponseParsingServi payload.sort = data.payload.sort; payload.scope = data.payload.scope; payload.configuration = data.payload.configuration; + payload.spellCheckSuggestions = data.payload.spellCheckSuggestions; const hitHighlights: MetadataMap[] = payload._embedded.objects .map((object) => object.hitHighlights) .map((hhObject) => { diff --git a/src/app/core/shared/search/models/search-query-response.model.ts b/src/app/core/shared/search/models/search-query-response.model.ts index 85e03377463..fc3df0cfb38 100644 --- a/src/app/core/shared/search/models/search-query-response.model.ts +++ b/src/app/core/shared/search/models/search-query-response.model.ts @@ -56,4 +56,10 @@ export abstract class SearchQueryResponse extends PaginatedList { @autoserialize facets: any; // TODO + + /** + * Spellcheck suggestions from the search backend + */ + @autoserialize + spellCheckSuggestions: string[]; } diff --git a/src/app/shared/search/search-results/search-results.component.html b/src/app/shared/search/search-results/search-results.component.html index e1039b8d31b..979808718fe 100644 --- a/src/app/shared/search/search-results/search-results.component.html +++ b/src/app/shared/search/search-results/search-results.component.html @@ -18,6 +18,20 @@

{{ (configuration ? configuration + '.search.results.head' : 'search.results } +@if (spellCheckSuggestions?.length > 0) { +
+ {{ 'search.results.did-you-mean' | translate }} + @for (suggestion of spellCheckSuggestions; track suggestion; let last = $last) { + + {{ suggestion }} + {{ last ? '' : ', ' }} + } +
+} @if (searchResults && searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0) {
{ - protected inAndOutputNames: (keyof SearchResultsComponent & keyof this)[] = ['linkType', 'searchResults', 'searchConfig', 'showCsvExport', 'showThumbnails', 'sortConfig', 'viewMode', 'configuration', 'disableHeader', 'selectable', 'context', 'hidePaginationDetail', 'selectionConfig', 'contentChange', 'deselectObject', 'selectObject']; + protected inAndOutputNames: (keyof SearchResultsComponent & keyof this)[] = ['linkType', 'searchResults', 'searchConfig', 'showCsvExport', 'showThumbnails', 'sortConfig', 'viewMode', 'configuration', 'disableHeader', 'selectable', 'context', 'hidePaginationDetail', 'selectionConfig', 'contentChange', 'deselectObject', 'selectObject', 'spellCheckSuggestions']; @Input() linkType: CollectionElementLinkType; @@ -42,6 +42,8 @@ export class ThemedSearchResultsComponent extends ThemedComponent