Skip to content

Commit

Permalink
Handle multi-word search queries
Browse files Browse the repository at this point in the history
In search, match every word of the query separately.  This solves issues
with reordered or missing words in a search query, which used to prevent
terms from being matched.
  • Loading branch information
skalee committed Jul 25, 2020
1 parent 3455d21 commit 4943ac3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions assets/js/concept-search-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ var latestQuery = null;
// TODO Support filters here maybe.
class SearchQuery {
constructor(queryString) {
this.queryString = queryString.toLowerCase();
this.searchWords = queryString.toLowerCase().match(/\p{Letter}+/ug) || [];
}

isEmpty() {
return this.queryString === "";
return this.searchWords.length == 0;
}

match(string) {
const stringLC = string.toLowerCase();
return stringLC.includes(this.queryString);
return this.searchWords.every((word) => stringLC.includes(word));
}
}

Expand Down

0 comments on commit 4943ac3

Please sign in to comment.