fix(keyword-search): add fuzzy search fallback for news

This commit is contained in:
2026-08-10 16:32:27 +02:00
parent c1692535a5
commit d8b7d8bc2e
5 changed files with 69 additions and 18 deletions
@@ -119,12 +119,23 @@
@if (!hasSearchInput()) {
<div class="no-results">
@if (fuzzySearch()) {
<span>
Keines der gewählten Keywords konnte einem Thema zugeordnet werden.
<span>Keine Keywords ausgewählt.</span>
</div>
} @else if (total() === 0) {
<div class="no-results">
@if (hasNarrowingFilters()) {
<span>Keine Nachrichten für die aktuellen Filter.</span>
<span class="no-results__hint">
Setzen Sie die Filter zurück, um mehr Ergebnisse zu sehen.
</span>
} @else if (searchedByTopics()) {
<span>Zu diesen Themen gibt es keine Nachrichten.</span>
<span class="no-results__hint">
Campus Aktuell deckt nicht jedes Forschungsthema ab. Schalten Sie die
Fuzzy Search aus, um direkt nach den Keywords zu suchen.
</span>
} @else {
<span>Keine Keywords ausgewählt.</span>
<span>Keine Nachrichten zu diesen Keywords gefunden.</span>
}
</div>
} @else {
@@ -169,7 +169,17 @@
.no-results {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
gap: 0.5rem;
padding: 2rem;
color: var(--sg-text-muted);
text-align: center;
&__hint {
max-width: 34rem;
color: var(--sg-text-soft);
font-size: 0.8125rem;
line-height: 1.5;
}
}
@@ -103,7 +103,7 @@ export class KeywordsToNewsResultsComponent {
readonly hasSearchInput = computed(() =>
this.fuzzySearch()
? this.state.topicIds().length > 0
? this.state.topicIds().length > 0 || this.state.keywords().length > 0
: this.state.keywords().length > 0,
);
@@ -122,6 +122,26 @@ export class KeywordsToNewsResultsComponent {
);
});
readonly hasNarrowingFilters = computed(() => {
const params = this.queryParamMap();
return (
!!params.get(keywordsNewsQueryParamKeys.relevance) ||
!!params.get(keywordsNewsQueryParamKeys.yearFrom) ||
!!params.get(keywordsNewsQueryParamKeys.yearTo) ||
this.selectedTopicIds().length > 0
);
});
readonly searchedByTopics = computed(() => {
if (!this.fuzzySearch()) {
return false;
}
const baseTopicIds = (this.queryParamMap().get('topics') ?? '')
.split(',')
.filter((value) => value.trim());
return baseTopicIds.length > 0 || this.selectedTopicIds().length > 0;
});
titleTmp = viewChild.required<TemplateRef<any>>('titleTmp');
dateTmp = viewChild.required<TemplateRef<any>>('dateTmp');
relevanceTmp = viewChild.required<TemplateRef<any>>('relevanceTmp');
@@ -32,7 +32,11 @@ export const keywordsNewsPageResolver: ResolveFn<NewsPage> = (route) => {
const filterTopicIds = params.getAll(keywordsNewsQueryParamKeys.topicId);
const fuzzy = params.get('fuzzy') === 'true';
if (fuzzy ? topicIds.length === 0 : keywords.length === 0) {
const canSearch = fuzzy
? topicIds.length > 0 || keywords.length > 0
: keywords.length > 0;
if (!canSearch) {
return of(emptyPage(page + 1, size));
}