Skip to content

Usage of Lunr js with Turkish language  #69

Description

@irfancnk

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions