-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lunr-languages? #22
Comments
I will update the link. |
Thanks for the answer, but unfortunately, it gives an error about lunr.SortedSet when I try it.
Here's my node.js code:
Am I doing it right or that's a legitimate error? |
Thanks! |
I think it needs some refactoring. Because it uses global lunr object which doesn't exist in elasticlunr implementation. |
@weixsong If I prepare this PR, will you merge it? |
Hi, @Kreozot , I did not use elasticlunr.js with other languages so I did not notice that it does not work with lunr-languages, and I have checked the code, it did need some refactor to support other languages to make elasticlunr.js more powerful. I will try to refactor the code to provide other language support. But if you could do that is good. But my idea is refactor totally to add other language support, that need to design a abstract interface that for function such as tokenizer, stemmer, etc. I dont want to just make a copy of Sorted_set in lunr.js, actually in the beginning I removed Sorted_set.js just because the performance of it and it's useless in elasticlunr.js. :) |
Wow, it will be cool! Good luck with that! So, for now it is possible to using lunr-languages with elasticlunr in node.js with this code (it needs to have lunr and lunr-languages in your deps, but do not need to edit any code): var elasticlunr = require('elasticlunr');
global.lunr = elasticlunr;
require('lunr/lib/sorted_set.js');
require('lunr-languages/lunr.stemmer.support.js')(elasticlunr);
require('lunr-languages/lunr.ru.js')(elasticlunr); |
Lunr-languages.js is now supported both in browser & Node.js, please try: Other LanguagesDefault supported language of elasticlunr.js is English, if you want to use elasticlunr.js to index other language documents, then you need to use elasticlunr.js combined with lunr-languages. Other languages example in BrowserSuppose you are using elasticlunr.js in browser for other languages, you could download the corresponding language support from lunr-languages, then include the scripts as: <script src="lunr.stemmer.support.js"></script>
<script src="lunr.de.js"></script> then, you could use elasticlunr.js as normal: var index = elasticlunr(function () {
// use the language (de)
this.use(elasticlunr.de);
// then, the normal elasticlunr index initialization
this.addField('title')
this.addField('body')
}); Pay attention to the special code: this.use(elasticlunr.de); If you are using other language, such as es(Spanish), download the corresponding this.use(elasticlunr.es); Other languages example in Node.jsSuppose you are using elasticlunr.js in Node.js for other languages, you could download the corresponding language support from lunr-languages, put the files var elasticlunr = require('elasticlunr');
require('./lunr.stemmer.support.js')(elasticlunr);
require('./lunr.de.js')(elasticlunr);
var index = elasticlunr(function () {
// use the language (de)
this.use(elasticlunr.de);
// then, the normal elasticlunr index initialization
this.addField('title')
this.addField('body')
}); For more details, please go to lunr-languages. |
@weixsong Is it possible to support multi-language feature? When the text contains strings in two different languages, e.g. Russian and English? |
Hi, have you solved this question? I also need to do a search where the article contains Russian and English text |
The README.md mentions using elasticlunr.js to index other language documents with lunr-languages, but the repository seems gone now. Can I still index, say, French documents, or it's only English-only for now?
The text was updated successfully, but these errors were encountered: