diff --git a/packages/cms/src/api/searchRoute.js b/packages/cms/src/api/searchRoute.js index 59f20af7a..785ee8068 100644 --- a/packages/cms/src/api/searchRoute.js +++ b/packages/cms/src/api/searchRoute.js @@ -578,7 +578,7 @@ module.exports = function(app) { let contentIds = []; const {searchIndexByLocale} = app.settings.cache; - if (CANON_CMS_LUNR && searchIndexByLocale[locale]) { + if (yn(CANON_CMS_LUNR) && searchIndexByLocale[locale]) { const terms = query.split(" ").map(d => `+${d}~1*`).join(" "); const lunrResults = searchIndexByLocale[locale].search(terms); contentIds = lunrResults.map(d => d.ref); diff --git a/packages/cms/src/cache/searchIndexByLocale.js b/packages/cms/src/cache/searchIndexByLocale.js index 7c1818252..e1c468971 100644 --- a/packages/cms/src/cache/searchIndexByLocale.js +++ b/packages/cms/src/cache/searchIndexByLocale.js @@ -1,5 +1,6 @@ const lunr = require("lunr"); require("lunr-languages/lunr.stemmer.support")(lunr); +const yn = require("yn"); const whitelist = ["ar", "da", "de", "du", "en", "es", "fi", "hi", "hu", "it", "ja", "jp", "nl", "no", "pt", "ro", "ru", "sv", "ta", "th", "tr", "vi", "zh"]; @@ -13,7 +14,7 @@ for (const locale of locales.filter(d => d !== "en")) { module.exports = async function(app) { - if (!CANON_CMS_LUNR) return {}; + if (!yn(CANON_CMS_LUNR)) return {}; const {db} = app;