Comments (11)
https://github.com/MihaiValentin/lunr-languages
from elasticlunr.js.
Lunr-languages.js is now supported both in browser & Node.js, please try:
Other Languages
Default 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 Browser
Suppose 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 lunr.es.js
file and lunr.stemmer.support.js
, and change the above line to:
this.use(elasticlunr.es);
Other languages example in Node.js
Suppose you are using elasticlunr.js in Node.js for other languages, you could download the corresponding language support from lunr-languages, put the files lunr.es.js
file and lunr.stemmer.support.js
in your project, then in your Node.js module, use elasticlunr.js as:
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.
from elasticlunr.js.
I will update the link.
from elasticlunr.js.
Thanks for the answer, but unfortunately, it gives an error about lunr.SortedSet when I try it.
lunr.fr.js:688
lunr.fr.stopWordFilter.stopWords = new lunr.SortedSet();
^
TypeError: lunr.SortedSet is not a function
at /home/juju/mlpsubs/lunr.fr.js:688:40
at Object.<anonymous> (/home/juju/mlpsubs/serialize.js:8:24)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:134:18)
at node.js:962:3
Here's my node.js code:
var lunr = require('elasticlunr');
require('./lunr.stemmer.support.js')(lunr);
require('./lunr.fr.js')(lunr);
var index = lunr(function() {
this.use(lunr.fr);
this.addField('text');
this.setRef('id');
this.saveDocument(false);
});
Am I doing it right or that's a legitimate error?
from elasticlunr.js.
Thanks!
from elasticlunr.js.
I think it would make sense to cherry pick this from lunr.js to improve compatibility.
I think it needs some refactoring. Because it uses global lunr object which doesn't exist in elasticlunr implementation.
from elasticlunr.js.
@weixsong If I prepare this PR, will you merge it?
from elasticlunr.js.
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.
:)
from 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);
from elasticlunr.js.
@weixsong Is it possible to support multi-language feature? When the text contains strings in two different languages, e.g. Russian and English?
from elasticlunr.js.
@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
from elasticlunr.js.
Related Issues (20)
- Modernizing code & build HOT 8
- remove a field after indexing
- The link to https://github.com/weixsong/lunr-languages is broken! HOT 1
- Separate document and query token pipelines? HOT 3
- Turn off stemmer for specific queries? HOT 1
- Support browser ES6 imports HOT 1
- Delegate or add maintainers HOT 4
- Typescript compile issue with addField HOT 2
- move to org HOT 4
- Unexpected search results HOT 7
- Stop words in hyphenated compounds HOT 2
- Search index by time
- single page simple example? HOT 1
- Feature Request: Binomial Coefficient Entropy Coding for Inverted Index Postings
- Facing this issue with importing elasticlunr TypeError: (0 , elasticlunr_1.default) is not a function HOT 1
- Show result for special characters in the search? HOT 1
- Speed
- synonym functionality
- "lunr is not defined" when strict parsing is enabled HOT 2
- Has anyone tried modifying elasticlunr to not use global variables?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticlunr.js.