From 029588f0afaa4180ad5bdc3548bb5fe7bf7f75bf Mon Sep 17 00:00:00 2001 From: Laton Vermette <1619661+latonv@users.noreply.github.com> Date: Thu, 1 May 2025 12:59:48 -0700 Subject: [PATCH] Turn more wikidata results into smart facets --- .../heuristics/wikidata/wikidata-heuristic.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts b/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts index c776be2f9..d953cd89d 100644 --- a/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts +++ b/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts @@ -73,11 +73,13 @@ export class WikidataHeuristic implements SmartQueryHeuristic { for (const [keyword, facets] of Object.entries(WIKIDATA_ENTITIES)) { const keywordRegex = new RegExp(`\\b${keyword}\\b`); - if (keywordRegex.test(searchResults.search[0]?.description)) { - const entityName = searchResults.search[0].label; - recommendations.push( - ...this.replaceQueryPlaceholders(facets, entityName), - ); + for (const searchResult of searchResults.search.slice(0, 3)) { + if (keywordRegex.test(searchResult?.description)) { + const entityName = searchResult.label; + recommendations.push( + ...this.replaceQueryPlaceholders(facets, entityName), + ); + } } }