1

I create and save my lunr index this way:

require("lunr-languages/lunr.stemmer.support")(lunr);
require("lunr-languages/lunr.multi")(lunr);
require("lunr-languages/lunr.it")(lunr);
const englishItalianSupport = lunr.multiLanguage("en", "it");

    let fullTextIndex = lunr(function() {

        this.use(englishItalianSupport);
        this.pipeline.add(improvedTrimmer); // I think this does not matter

        this.ref("id");
        this.field("body");
        this.metadataWhitelist = ["position"];
        this.add({...});
        ...
     }

Then I save it to be reused in the following sessions.

In the lunr-languages/README.md there is this line:

If you serialize the index and load it in another script, you'll have to initialize the multi-language support in that script, too, like this:

lunr.multiLanguage('en', 'it');
var idx = lunr.Index.load(serializedIndex);

Is this needed? This line generates the warning: Overwriting existing registered function: lunr-multi-trimmer-en-it. Remember, this warning was generated by the this.use() call during the index generation before moving it outside the lunr() call.

Also, should I reference my improvedTrimmer when loading the index? If yes, how?

Thanks for clarifying!

SiliconValley
  • 1,465
  • 17
  • 30

0 Answers0