I am trying to use Lunr library in my nodejs environment. Here is the code block that makes the basic search.
const lunr = require("lunr");
require('lunr-languages/lunr.stemmer.support.js')(lunr);
require('lunr-languages/lunr.tr.js')(lunr);
var idx = lunr(function () {
this.use(lunr.tr);
this.ref('name');
this.field('text');
this.metadataWhitelist = ['position'];
this.add({
"name": "./file1.txt",
"text": "türkçe"
});
this.add({
"name": "./file2.txt",
"text": "kullanıcı"
});
});
function searchFor(token) {
let searchResult = idx.search(`*${token}*`);
console.log(searchResult.length);
}
searchFor("türkçe")
searchFor("kullanıcı")
The first search hits 1 result as expected. However the second one finds no match. I wonder the reason behind. I have tried using the multi-language as well by adding this.use(lunr.multiLanguage("tr")); and removing this.use(lunr.tr);. Also I tried removing the wildcards * from my search that hits a result but that is not the scenario I need. Is it a problem with the 'tr' support or there is a misunderstanding with my usage?
I am trying to use Lunr library in my nodejs environment. Here is the code block that makes the basic search.
The first search hits 1 result as expected. However the second one finds no match. I wonder the reason behind. I have tried using the multi-language as well by adding
this.use(lunr.multiLanguage("tr"));and removingthis.use(lunr.tr);. Also I tried removing the wildcards*from my search that hits a result but that is not the scenario I need. Is it a problem with the 'tr' support or there is a misunderstanding with my usage?