diff --git a/app/frontend/modules/search.js b/app/frontend/modules/search.js
index 5687692ad..91966be9a 100644
--- a/app/frontend/modules/search.js
+++ b/app/frontend/modules/search.js
@@ -12,13 +12,9 @@ const clean = (text) =>
.toLowerCase();
const cleanseOption = (option) => {
- const synonyms = (option.synonyms || []).map(clean);
-
option.clean = {
name: clean(option.name),
nameWithoutStopWords: removeStopWords(option.name),
- synonyms: synonyms,
- synonymsWithoutStopWords: synonyms.map(removeStopWords),
boost: option.boost || 1,
};
@@ -45,42 +41,19 @@ const startsWith = (word, query) => word.search(startsWithRegExp(query)) === 0;
const wordsStartsWithQuery = (word, regExps) =>
regExps.every((regExp) => word.search(regExp) >= 0);
-const anyMatch = (words, query, evaluatorFunc) =>
- words.some((word) => evaluatorFunc(word, query));
-const synonymsExactMatch = (synonyms, query) =>
- anyMatch(synonyms, query, exactMatch);
-const synonymsStartsWith = (synonyms, query) =>
- anyMatch(synonyms, query, startsWith);
-
-const wordInSynonymStartsWithQuery = (synonyms, startsWithQueryWordsRegexes) =>
- anyMatch(synonyms, startsWithQueryWordsRegexes, wordsStartsWithQuery);
-
-const calculateWeight = (
- { name, synonyms, nameWithoutStopWords, synonymsWithoutStopWords },
- query
-) => {
+const calculateWeight = ({ name, nameWithoutStopWords }, query) => {
const queryWithoutStopWords = removeStopWords(query);
if (exactMatch(name, query)) return 100;
if (exactMatch(nameWithoutStopWords, queryWithoutStopWords)) return 95;
- if (synonymsExactMatch(synonyms, query)) return 75;
- if (synonymsExactMatch(synonymsWithoutStopWords, queryWithoutStopWords))
- return 70;
-
if (startsWith(name, query)) return 60;
if (startsWith(nameWithoutStopWords, queryWithoutStopWords)) return 55;
-
- if (synonymsStartsWith(synonyms, query)) return 50;
- if (synonymsStartsWith(synonyms, queryWithoutStopWords)) return 40;
-
const startsWithRegExps = queryWithoutStopWords
.split(/\s+/)
.map(startsWithRegExp);
if (wordsStartsWithQuery(nameWithoutStopWords, startsWithRegExps)) return 25;
- if (wordInSynonymStartsWithQuery(synonymsWithoutStopWords, startsWithRegExps))
- return 10;
return 0;
};
@@ -118,10 +91,8 @@ export const sort = (query, options) => {
export const suggestion = (value, options) => {
const option = options.find((o) => o.name === value);
if (option) {
- const html = option.append
- ? `${value} ${option.append}`
- : `${value}`;
- return option.hint ? `${html}
${option.hint}` : html;
+ const html = `${value}`;
+ return html;
} else {
return `No results found`;
}
@@ -130,11 +101,6 @@ export const suggestion = (value, options) => {
export const enhanceOption = (option) => {
return {
name: option.label,
- synonyms: option.getAttribute("data-synonyms")
- ? option.getAttribute("data-synonyms").split("|")
- : [],
- append: option.getAttribute("data-append"),
- hint: option.getAttribute("data-hint"),
boost: parseFloat(option.getAttribute("data-boost")) || 1,
};
};