我想在 lunr-language 添加的多语言之前添加一个修剪器(称为改进的修剪器)。我找不到的是如何将现有函数传递给this.pipeline.before()
or this.pipeline.after()
。这是我总是抛出“错误:找不到现有Fn”的尝试:
fullTextIndex = lunr(function() {
this.use(lunr.multiLanguage("en", "it"));
// This works, but put my trimmer at the end of the pipeline
// this.pipeline.add(improvedTrimmer);
// This says lunr.trimmer not found. Idem with this.trimmer
// this.pipeline.after(lunr.trimmer, improvedTrimmer);
// This seems the most logical choice, but no way (the string is
// the synthesized trimmer label by the multilanguage plugin
// this.pipeline.before("lunr-multi-trimmer-en-it", improvedTrimmer);
// This works, but seems very a dirty workaround
this.pipeline.after(this.pipeline._stack[0], improvedTrimmer);
在网络上,很少有建议不适用于当前版本的 lunr。