docfxlunrjs

Docfx Russian language search


How to make docfx to search in Russian language? It searches English words just fine, but not Russian words. I tried to debug it and can see that it uses lunr library for search. How can I replace standard lunr library with Russian lunr in docfx?


Solution

  • Turns out to be quite easy: In order to support other languages apart from those which supports lunr use this repo: https://github.com/MihaiValentin/lunr-languages

    Open search-worker.js file from docfx and modify it a bit as readme at github suggest:

    Add imports

    importScripts('lunr.stemmer.support.js');
    importScripts('lunr.ru.js');
    

    Copy these files from github to the folder with lunr.js

    Modify the following method:

    var lunrIndex = lunr(function() {
          this.pipeline.remove(lunr.stopWordFilter);
    Add this line...>this.use(lunr.ru);
          this.ref('href');
    

    Enjoy.