lunr-languages icon indicating copy to clipboard operation
lunr-languages copied to clipboard

Load an index with a custom pipeline

Open amsdamsgram opened this issue 7 years ago • 1 comments

Hey,

I'm having a Error: Cannot load un-registered function: trimmer-fr when trying to load an index built with french stemmer/stopWords.

I have built the index following the doc:

var lunr = require('./lunr.min.js'), fs = require('fs');
require('./lunr.stemmer.support.js')(lunr);
require('./lunr.fr.js')(lunr);

var idx = lunr(function() {
  this.use(lunr.fr);

// ...
});

Then I load the index like this: lunr.Index.load(idx);

I'm doing this because I have the index file on a static host environment and I am fetching it in my mobile app. This way I don't have to bundle my app with it. For now, to make it works, I'm replacing the pipeline with the default one when I fetch it. idx.pipeline = idx.pipeline.map(pipe => pipe.replace('-fr', ''))

Am I breaking something if I do this? Is there any other workarounds/fix?

Thanks!

amsdamsgram avatar Feb 27 '17 09:02 amsdamsgram

I am not experiencing this with my serialized indexes. But your example seems to be missing something.

Before loading the serialized index, has the support already been added?

    var lunr = require('./lunr.min.js');
    require('./lunr.stemmer.support.js')(lunr);
    require('./lunr.fr.js')(lunr);

    var jsonIndex = <something to get JSON Serialized Index>
   var idx = lunr.Index.load(jsonIndex);

The above works in my app.

johndobrien avatar Sep 22 '17 13:09 johndobrien