From 59f55710035d88d4ca2f1d5a5a801787ff7bb1b6 Mon Sep 17 00:00:00 2001 From: wei song Date: Tue, 14 Jun 2016 17:39:39 +0800 Subject: [PATCH] Update README.md --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index d7fd536c..18695f07 100644 --- a/README.md +++ b/README.md @@ -347,6 +347,42 @@ var customized_stop_words = ['an', 'hello', 'xyzabc']; elasticlunr.addStopWords(customized_stop_words); ``` +## 7. Use elasticlunr in Node.js + +Elasticlunr support Node.js, you could use elastilunr in node.js as a node-module. + +Install elasticlunr by: +```javascript +npm install elasticlunr +``` + +then in your node.js project or in node.js console: +```javascript +var elasticlunr = require('elasticlunr'); + +var index = elasticlunr(function () { + this.addField('title') + this.addField('body') +}); + +var doc1 = { + "id": 1, + "title": "Oracle released its latest database Oracle 12g", + "body": "Yestaday Oracle has released its new database Oracle 12g, this would make more money for this company and lead to a nice profit report of annual year." +} + +var doc2 = { + "id": 2, + "title": "Oracle released its profit report of 2015", + "body": "As expected, Oracle released its profit report of 2015, during the good sales of database and hardware, Oracle's profit of 2015 reached 12.5 Billion." +} + +index.addDoc(doc1); +index.addDoc(doc2); + +index.search("Oracle database profit"); +``` + # Contributing See the [`CONTRIBUTING.mdown` file](CONTRIBUTING.mdown).