diff --git a/packages/gatsby-theme-carbon/config/lunr-options.js b/packages/gatsby-theme-carbon/config/lunr-options.js index e18721b5a..9a86394e4 100644 --- a/packages/gatsby-theme-carbon/config/lunr-options.js +++ b/packages/gatsby-theme-carbon/config/lunr-options.js @@ -1,14 +1,8 @@ -const removeStemmerPlugin = lunr => builder => { - builder.pipeline.remove(lunr.stemmer); - builder.searchPipeline.remove(lunr.stemmer); -}; - module.exports = { languages: [ { name: 'en', filterNodes: node => node.context && node.context.MdxNode, - plugins: [removeStemmerPlugin], }, ], fields: [ diff --git a/packages/gatsby-theme-carbon/src/components/GlobalSearch/GlobalSearch.js b/packages/gatsby-theme-carbon/src/components/GlobalSearch/GlobalSearch.js index bd20ed658..2a3d39973 100644 --- a/packages/gatsby-theme-carbon/src/components/GlobalSearch/GlobalSearch.js +++ b/packages/gatsby-theme-carbon/src/components/GlobalSearch/GlobalSearch.js @@ -36,11 +36,15 @@ const MAX_RESULT_LIST_SIZE = 8; const search = _throttle(queryString => { if (window.__LUNR__) { - const lunrIndex = window.__LUNR__.en; - const searchResults = lunrIndex.index - .search(`${queryString}*`) - .slice(0, MAX_RESULT_LIST_SIZE); - return searchResults.map(({ ref }) => lunrIndex.store[ref]); + try { + const lunrIndex = window.__LUNR__.en; + const searchResults = lunrIndex.index + .search(`${queryString}*`) + .slice(0, MAX_RESULT_LIST_SIZE); + return searchResults.map(({ ref }) => lunrIndex.store[ref]); + } catch { + console.error(`Lunr is having issues querying for '${queryString}'`); + } } }, 150);