Skip to content

Commit

Permalink
Display all semantic results if no fulltext (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrehault authored Mar 20, 2023
1 parent 109317f commit 6cfb308
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libs/search-widget/src/core/stores/search.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ export const smartResults = searchState.reader<Search.SmartResult[]>((state) =>
// unless there are some non-latin characters (because in Chinese for example there is no space between words)
const nonLatinChars = state.query.trim().replace(LATIN_CHAR, '');
const looksLikeKeywordSearch = state.query.split(' ').length < 3 && nonLatinChars.length < 2;
// if not a keyword search, add the 2 best semantic sentences
// if not a keyword search, add semantic sentences
if (!looksLikeKeywordSearch) {
const twoBestSemantic = semanticResults.slice(0, 2);
twoBestSemantic.forEach((sentence) => {
// if no fulltext results, we take all the semantic results, otherwise we take only the first 2
const bestSemantic = fullTextResults.length === 0 ? semanticResults : semanticResults.slice(0, 2);
bestSemantic.forEach((sentence) => {
const resource = allResources[sentence.rid];
const containingParagraph = state.results.paragraphs?.results?.find(
(p) =>
Expand Down

0 comments on commit 6cfb308

Please sign in to comment.