{"_id":"@egopulse/elasticlunr","_rev":"3-82c79c266ffc9766f51303491e18da5d","name":"@egopulse/elasticlunr","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@egopulse/elasticlunr","description":"Copy code from http://weixsong.github.io","version":"0.1.0","author":{"name":"Hung"},"keywords":["search","text retrieval","offline search","full text search"],"homepage":"http://weixsong.github.io","bugs":{"url":"https://github.com/weixsong/elasticlunr.js/issues"},"main":"elasticlunr.js","license":"MIT","repository":{"type":"git","url":"git+https://github.com/weixsong/elasticlunr.js.git"},"devDependencies":{"doxx":"1.4.0","phantomjs":"1.9.8","uglify-js":"2.6.0"},"scripts":{"test":"make test","start":"node server.js"},"gitHead":"cb06be7452f61d161f6377aa609be04719ed6b64","_id":"@egopulse/elasticlunr@0.1.0","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"egopulse","email":"hung@ego-pulse.com"},"dist":{"integrity":"sha512-mD1nM91JSgEJvkj2pqdmv/qPg3+ESoAMevdqHLHWwkNT9CDW314mfONeBsUcrVGZGdRvOGN62jcBx+Tbnoyp+Q==","shasum":"1ba88f0401ed80470b45f5a6d4acbd578792fd89","tarball":"https://registry.npmjs.org/@egopulse/elasticlunr/-/elasticlunr-0.1.0.tgz","fileCount":95,"unpackedSize":2407016,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb2r5NCRA9TVsSAnZWagAAw5wP/1NxOhNt6QcJeKnD/nV2\nIFgroyQWz+2HO9hFvojCOOtbPrXU8KAN4TZV/ABHiJ+w7vpIGvFrIdM0U8Oy\nSFimv3ElgoOXUbUdjGgCOhRcWIuSwMeXucoK8KLJRJW7CaTmjv/SWxM/R5NZ\n/sTGz4jct8S1n/NWomONfHRsom33CA7vj5JoGPb/1cUZU2RfsaKPd9dPMUBq\ns8S9f5c7PijMRfhjHtVg/CPYqgRHyA8+hlGIPIz+HzVC/L1iYpXf0w7zvOO+\n61iw8k+ErlJvqN/8ExN6hOuzflxfA6Nf6P+QhlOwOL/RWvBun8Q9Ca6aQlXW\n6vzKn9oVe+Z5Ml+bhOcn0Nb7SMEIa+WjHZAWXxHM7UAhb5+YSRjFUpQF+91b\nUsSrGWRHlUla1XnQ5DNmUUi+pKh2IU/mouSmbArb0Yqm6PXFeCy3RjCWHP2F\nage04YVJ+n7U7rS006htNqdHmXJ+bRBWBXWYT12p9sodXZdJubcleduHpl35\nBhIYvszSCpYvJ7qZUSRqB/yQaRGCeb3OM9ibOPvYfuTm2gt7XxLSbtq9vSBd\nN1wnumGUhyTx1EOZ10Ub4GgtGoOiTU/ysKJHB6bjp7zRIEKzvDUEC7bN/9dR\nrXcsAK1J8e2CdViWantwlsUmOb3WOjEWwcXTZv/p3pY7DQeAc4LTzrYRyVto\nMoZD\r\n=Ry7W\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFAW1FXZ8a8VNzLkoM2aq7u6sHymfMbT5RT0fgTAfgdPAiEAoZLXVDVxtmR+3gwoZ0dmfWkOJZ5JhOipUhBvTxK0h/M="}]},"maintainers":[{"name":"egopulse","email":"hung@ego-pulse.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/elasticlunr_0.1.0_1541062220200_0.3248965744967862"},"_hasShrinkwrap":false},"0.1.1":{"name":"@egopulse/elasticlunr","description":"Copy code from http://weixsong.github.io","version":"0.1.1","author":{"name":"Hung"},"keywords":["search","text retrieval","offline search","full text search"],"homepage":"http://weixsong.github.io","bugs":{"url":"https://github.com/weixsong/elasticlunr.js/issues"},"main":"elasticlunr.js","license":"MIT","repository":{"type":"git","url":"git+https://github.com/weixsong/elasticlunr.js.git"},"devDependencies":{"doxx":"1.4.0","phantomjs":"1.9.8","uglify-js":"2.6.0"},"scripts":{"test":"make test","start":"node server.js"},"gitHead":"cb06be7452f61d161f6377aa609be04719ed6b64","_id":"@egopulse/elasticlunr@0.1.1","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"egopulse","email":"hung@ego-pulse.com"},"dist":{"integrity":"sha512-Kzfauu3UpMFjamVIl6lJrO1/Bao8MJEoepnkyS1+TQDVB68/9ONnRGO3rFpXnxoKZa6+B/wHl71h+Mem+gaq6Q==","shasum":"951ac82140ce6255e92c61e166a0f080c9fe37c3","tarball":"https://registry.npmjs.org/@egopulse/elasticlunr/-/elasticlunr-0.1.1.tgz","fileCount":97,"unpackedSize":2440783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb2tbBCRA9TVsSAnZWagAAMxIP+QEx5gPtaVWefbDUEYFn\nmCNeL5P6fJ4MhDwBLtmTPQXGPM+JPSEIFDje6e/4Rrz4Zp7hMZZA3cqhoNTK\nEOlW2NOMy77bSYhTZ7koi8/+OrHSsu421acFJTAjo82mcD77OUNhoqlvUVVU\nYZ8zlYnfPTPb9X58FKOblN2H3wjWlxebG9ZCI4pMmxmTtANrmBg1ZhvSgGwz\nhCansAzBvH5sPYkTQS2uOL4IoRJ1E7+sCgssEuK7RNKBE7qrf6OVoKN4waC0\nqIB92L/te5kgBp6bDzV7i9SjWY6QP2MXJa+u9/bVCUszYN6SQAoKkB6YCi6W\nMOHRYXPfyXSPchQ5b4W+cpwtIZ+tZPYvSKd2KY2O85L3Hpb526NSCMXlXA2s\nZX+GcWGbJkJ0P7zSFtuVb/PMch6uLx247rt3wDNhcU5HVvG2KOl44hC34To5\nvItrXZruGrjeunYBf7nm2Ha7Ao8SXA8AuO5B/0s4iNGd/OoMKEDGrFZW75xU\nRDuZOYnAnv71lJkhhv1GpMJtXP2xSou7LOrEc/qNd2kKCQRR+aYDa7j0gcCx\nNE6p/avwNoX46d3Q2fSorPJBZ+qjysUBeA7fCiFABoJtqvFHyeUdMKVVQK23\n6eZGA8W+LwZYZtfaeo5CcVK7uEbLTezxIXddSgxpDYOaqv7L1OImNcYRr+qH\n9CoA\r\n=R5ch\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF6G1bkAUG4vjz0kPnHrQszsCThsQxD81KlJ8nXEqE3EAiEAwpRis2FcCBNPe/aaoURnNQysQwbUlvz9jesCOxHTe7A="}]},"maintainers":[{"name":"egopulse","email":"hung@ego-pulse.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/elasticlunr_0.1.1_1541068480859_0.009777416417931395"},"_hasShrinkwrap":false},"0.1.2":{"name":"@egopulse/elasticlunr","description":"Copy code from http://weixsong.github.io","version":"0.1.2","author":{"name":"Hung"},"keywords":["search","text retrieval","offline search","full text search"],"homepage":"http://weixsong.github.io","bugs":{"url":"https://github.com/weixsong/elasticlunr.js/issues"},"main":"elasticlunr.js","license":"MIT","repository":{"type":"git","url":"git+https://github.com/weixsong/elasticlunr.js.git"},"devDependencies":{"doxx":"1.4.0","phantomjs":"1.9.8","uglify-js":"2.6.0"},"scripts":{"test":"make test","start":"node server.js"},"gitHead":"cb06be7452f61d161f6377aa609be04719ed6b64","_id":"@egopulse/elasticlunr@0.1.2","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"egopulse","email":"hung@ego-pulse.com"},"dist":{"integrity":"sha512-vGg4GpG4XwYEagIz+IPUQ2eWvDnH7A+v86jFy745WT+8bKtn/BnSp7O869hlOZkdCcIntgD2Q9lMbCcycOdixA==","shasum":"1b1b0f48dda25f4fd4a8ef05481d25f9bb7d1e1a","tarball":"https://registry.npmjs.org/@egopulse/elasticlunr/-/elasticlunr-0.1.2.tgz","fileCount":96,"unpackedSize":2426324,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb2th0CRA9TVsSAnZWagAAzR8P/0GXychH2yrpkBMwNvbp\nstmDxxW+zWDdItrFvZTB/lGD3WuBC1EDLuBpjS7Sqf8yJt2Ax4wOTToSo+dE\nkTVNq8FyizzU6bkL5PmrlOy2NlJu/rCbmFkS1suVbYmxuBLZjVCaZxKgjQ0O\npJgDXR4AurgSgQ7t/NIWTUpXzidkwCzwMGLf8Lwz/Bd4X07fZc2RSZQaZ07V\nwozXfX3PlCCcH0rc5D6WrIbq5uvJDdfBcqqes+3uqSR2SJ/waRaxlMCym1eH\nsUSxIWO/crCdKIziclKdC2g+FNteffpXepsBWJGhE2E327CtujtNP1nsdXEU\nBrjPmPPLnIuHPF8Qi82VhW01JvAN5ZXTEh/Zh/rbmIAsfMtYVSOCP6lJXDrt\nJpcRAMi8AIJneQCk0cQMB+lfxUADyxd6AJjlEMgJsRXyBfOH11If9uCe4iiE\nZDcY+pgi/XKrk7mtN65+u+9a4Ks7BHds4vBaFuZ3wN7feHsAXtbtznd79tD1\ndDHG/At37uIZkbZVb9TpuGx9mtA16Edpn7OWJaviyRgvArwbrsjYSuwecrAA\nkNC+aDTdM4/+PVYlkXsDzO2jEib6s3TigKFbiFEn7CFTncj7xiOA/Eyr3HmM\nvya4aVvVKTZeHeilqQh+TtW8slGjfuAp1MC0ylh2aS0/0MSG+/9qQnUiEihj\nv4m8\r\n=wMp6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCzBiC4OO01WDSgIT3j0Fi2i2n/898GWu8IJ+oeu5/RVwIhANXVLrsGPFUM0amys0n0iAxlbW9Ks+jjDYDWBF1gut1Y"}]},"maintainers":[{"name":"egopulse","email":"hung@ego-pulse.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/elasticlunr_0.1.2_1541068915415_0.6656003561013402"},"_hasShrinkwrap":false}},"time":{"created":"2018-11-01T08:50:20.024Z","0.1.0":"2018-11-01T08:50:20.420Z","modified":"2022-04-05T06:57:29.016Z","0.1.1":"2018-11-01T10:34:41.053Z","0.1.2":"2018-11-01T10:41:55.581Z"},"maintainers":[{"name":"egopulse","email":"hung@ego-pulse.com"}],"description":"Copy code from http://weixsong.github.io","homepage":"http://weixsong.github.io","keywords":["search","text retrieval","offline search","full text search"],"repository":{"type":"git","url":"git+https://github.com/weixsong/elasticlunr.js.git"},"author":{"name":"Hung"},"bugs":{"url":"https://github.com/weixsong/elasticlunr.js/issues"},"license":"MIT","readme":"# Elasticlunr.js\n\n[![Build Status](https://travis-ci.org/weixsong/elasticlunr.js.svg?branch=master)](https://travis-ci.org/weixsong/elasticlunr.js)\n[![npm version](https://badge.fury.io/js/elasticlunr.svg)](https://badge.fury.io/js/elasticlunr)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/weixsong/elasticlunr.js/master/LICENSE)\n[![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badge/)\n\n# Contributor Welcome!!!\n\nAs I'm now focusing on new domain, hope that someone who interested on this project could help to maintain this repository.\n\nIf anyone want to help to maintain this repo, please leave a message and I could add you to the admin account. Thanks very much~~~ :)\n\n# Milestone\n\nThanks that so many people use and love Elasticlunr.js, it has received more than 500 stars.\n\n# Elasticlunr.js\n\nElasticlunr.js is a lightweight full-text search engine developed in JavaScript for browser search and offline search.\nElasticlunr.js is developed based on Lunr.js, but more flexible than lunr.js. Elasticlunr.js provides Query-Time boosting, field search, more rational scoring/ranking methodology, fast computation speed and so on.\nElasticlunr.js is a bit like Solr, but much smaller and not as bright, but also provide flexible configuration, query-time boosting, field search and other features.\n\n# Why You Need Lightweight Offline Search?\n\n1. In some systems, you don't want to deploy any **complex full-text search engine** (such as Lucene, Elasticsearch, Sphinx, etc.), you only want to provide some static web pages and provide search functionality, then you could build index in previous and load index in client side (such as Browser).\n2. Provide offline search functionality. For some documents, the user usually downloads these documents, you could build index and put index in the documents package, then provide offline search functionality.\n3. For limited or restricted networks, such WAN or LAN, offline search is a better choice.\n4. For mobile devices, Iphone or Android phones, network traffic may be very expensive, so offline search is a good choice.\n5. If you want to provide search functionality in your Node.js system, and you don't want to use a complex system, or you only need to support thousands of documents, then Elasticlunr.js is what you want to use.\n\n# Key Features Comparing with Lunr.js\n\n1. **Query-Time Boosting**, you don't need to set up boosting weight in index building procedure, Query-Time Boosting make it more flexible so you could try different boosting schemes.\n2. **More Rational Scoring Mechanism**, Elasticlunr.js uses a similar scoring mechanism as Elasticsearch, and also this scoring mechanism is used by Lucene.\n3. **Field-Search**, you can choose which field to index and which field to search.\n4. **Boolean Model**, you can set which field to search and the boolean model for each query token, such as \"OR\", \"AND\".\n5. **Combined Boolean Model, TF/IDF Model and the Vector Space Model**, makes the results ranking more reliable.\n6. **Fast**, Elasticlunr.js removed TokenCorpus and Vector from lunr.js, by using combined model there is **no** need to compute the vector of a document and query string to compute similarity of query and matched document, this improves the search speed significantly.\n7. **Small Index Size**, Elasticlunr.js did not store TokenCorpus because there is no need to compute query vector and document vector, then the index file is small, and also user can choose if they need to store the origianl JSON doc, if user cares more about the index size, they can choose not store the original JSON doc. This can reduce the index size significantly. This is especially helpful when elasticlunr.js is used as offline search. The index size is about half size of lunr.js index file.\n\n## Example\n\nA very simple search index can be created using the following scripts:\n\n```javascript\nvar index = elasticlunr(function () {\n    this.addField('title');\n    this.addField('body');\n    this.setRef('id');\n});\n```\n\nAdding documents to the index is as simple as:\n\n```javascript\nvar doc1 = {\n    \"id\": 1,\n    \"title\": \"Oracle released its latest database Oracle 12g\",\n    \"body\": \"Yesterday 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.\"\n}\n\nvar doc2 = {\n    \"id\": 2,\n    \"title\": \"Oracle released its profit report of 2015\",\n    \"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.\"\n}\n\nindex.addDoc(doc1);\nindex.addDoc(doc2);\n```\n\nThen searching is as simple:\n\n```javascript\nindex.search(\"Oracle database profit\");\n```\n\nAlso, you could do query-time boosting by passing in a configuration.\n\n```javascript\nindex.search(\"Oracle database profit\", {\n    fields: {\n        title: {boost: 2},\n        body: {boost: 1}\n    }\n});\n```\n\nThis returns a list of matching documents with a score of how closely they match the search query:\n\n```javascript\n[{\n    \"ref\": 1,\n    \"score\": 0.5376053707962494\n},\n{\n    \"ref\": 2,\n    \"score\": 0.5237481076838757\n}]\n```\n\nYou can also query on different terms for each field.\n\n```javascript\nindex.search({\n  title: 'database',\n  body:  'profit',\n});\n```\n\nIf user doesn't want to store the original JSON documents, they can use the following setting:\n```javascript\nvar index = elasticlunr(function () {\n    this.addField('title');\n    this.addField('body');\n    this.setRef('id');\n    this.saveDocument(false);\n});\n```\n\nThen elasticlunr.js will not store the JSON documents, this will reduce the index size, but also bring some inconvenience such as update a document or delete a document by document id or reference. Actually most of the time user will not udpate or delete a document from index.\n\n[API documentation](http://elasticlunr.com/docs/index.html) is available, as well as a [full working example](http://elasticlunr.com/example/index.html).\n\n## Description\n\nElasticlunr.js is developed based on Lunr.js, but more flexible than lunr.js. Elasticlunr.js provides Query-Time Boosting, Field Search, more rational scoring/ranking methodology, flexible configuration and so on.\nA bit like Solr, but much smaller and not as bright, but also provide flexible configuration, query-time boosting, field search, etc.\n\n## Installation\n\nSimply include the elasticlunr.js source file in the page that you want to use it.  Elasticlunr.js is supported in all modern browsers.\n\nBrowsers that do not support ES5 will require a JavaScript shim for Elasticlunr.js to work. You can either use [Augment.js](https://github.com/olivernn/augment.js), [ES5-Shim](https://github.com/kriskowal/es5-shim) or any library that patches old browsers to provide an ES5 compatible JavaScript environment.\n\n# Documentation\n\nThis part only contain important apects of elasticlunr.js, for the whole documentation, please go to [API documentation](http://elasticlunr.com/docs/index.html).\n\n## 1. Build Index\n\nWhen you first create a index instance, you need to specify which field you want to index. If you did not specify which field to index, then no field will be searchable for your documents.\nYou could specify fields by:\n```javascript\nvar index = elasticlunr(function () {\n    this.addField('title');\n    this.addField('body');\n    this.setRef('id');\n});\n```\n\nYou could also set the document reference by <code>this.setRef('id')</code>, if you did not set document ref, elasticlunr.js will use **'id'** as default.\n\nYou could do the above index setup as followings:\n```javascript\nvar index = elasticlunr();\nindex.addField('title');\nindex.addField('body');\nindex.setRef('id');\n```\n\nAlso you could choose not store the original JSON document to reduce the index size by:\n```javascript\nvar index = elasticlunr();\nindex.addField('title');\nindex.addField('body');\nindex.setRef('id');\nindex.saveDocument(false);\n```\n\n\n## 2. Add document to index\n\nAdd document to index is very simple, just prepare you document in JSON format, then add it to index.\n\n```javascript\nvar doc1 = {\n    \"id\": 1,\n    \"title\": \"Oracle released its latest database Oracle 12g\",\n    \"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.\"\n}\n\nvar doc2 = {\n    \"id\": 2,\n    \"title\": \"Oracle released its profit report of 2015\",\n    \"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.\"\n}\n\nindex.addDoc(doc1);\nindex.addDoc(doc2);\n```\n\nIf your JSON document contains field that not configured in index, then that field will not be indexed, which means that field is not searchable.\n\n## 3. Remove document from index\n\nElasticlunr.js support remove a document from index, just provide JSON document to <code>elasticlunr.Index.prototype.removeDoc()</code> function.\n\nFor example:\n```javascript\nvar doc = {\n    \"id\": 1,\n    \"title\": \"Oracle released its latest database Oracle 12g\",\n    \"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.\"\n}\n\nindex.removeDoc(doc);\n```\n\nRemove a document will remove each token of that document's each field from field-specified inverted index.\n\n## 4. Update a document in index\nElasticlunr.js support update a document in index, just provide JSON document to <code>elasticlunr.Index.prototype.updateDoc()</code> function.\n\nFor example:\n```javascript\nvar doc = {\n    \"id\": 1,\n    \"title\": \"Oracle released its latest database Oracle 12g\",\n    \"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.\"\n}\n\nindex.updateDoc(doc);\n```\n\n## 5. Query from Index\n\nElasticlunr.js provides flexible query configuration, supports query-time boosting and Boolean logic setting.\nYou could setup a configuration tell elasticlunr.js how to do query-time boosting, which field to search in, how to do the boolean logic.\nOr you could just use it by simply provide a query string, this will aslo works perfectly because the scoring mechanism is very efficient.\n\n### 5.1 Simple Query\n\n**Because elasticlunr.js has a very perfect scoring mechanism, so for most of your requirement, simple search would be easy to meet your requirement.**\n\n```javascript\nindex.search(\"Oracle database profit\");\n```\n\nOutput is a results array, each element of results array is an Object contain a <code>ref</code> field and a <code>score</code> field.\n<code>ref</code> is the document reference.\n<code>score</code> is the similarity measurement.\n\nResults array is sorted descent by <code>score</code>.\n\n### 5.2 Configuration Query\n\n#### 5.2.1 **Query-Time Boosting**\n\nSetup which fields to search in by passing in a JSON configuration, and setup boosting for each search field.\nIf you setup this configuration, then elasticlunr.js will only search the query string in the specified fields with boosting weight.\n\n**The scoring mechanism used in elasticlunr.js is very complex**, please goto [details](https://www.elastic.co/guide/en/elasticsearch/guide/current/practical-scoring-function.html) for more information.\n\n\n```javascript\nindex.search(\"Oracle database profit\", {\n    fields: {\n        title: {boost: 2},\n        body: {boost: 1}\n    }\n});\n```\n\n#### 5.2.2 **Boolean Model**\n\nElasticlunr.js also support boolean logic setting, if no boolean logic is setted, elasticlunr.js use \"OR\" logic defaulty. By \"OR\" default logic, elasticlunr.js could reach a high **Recall**.\n\n```javascript\nindex.search(\"Oracle database profit\", {\n    fields: {\n        title: {boost: 2},\n        body: {boost: 1}\n    },\n    bool: \"OR\"\n});\n```\n\nBoolean model could be setted by global level such as the above setting or it could be setted by field level, if both global and field level contains a \"bool\" setting, field level setting will overwrite the global setting.\n```javascript\nindex.search(\"Oracle database profit\", {\n    fields: {\n        title: {boost: 2, bool: \"AND\"},\n        body: {boost: 1}\n    },\n    bool: \"OR\"\n});\n```\nThe above setting will search <code>title</code> field by **AND** model and other fields by \"OR\" model.\nCurrently if you search in multiply fields, resutls from each field will be merged together to give the query results. In the future elasticlunr will support configuration that user could set how to combine the results from each field, such as \"most_field\" or \"top_field\".\n\n#### 5.2.3 **Token Expandation**\nSometimes user want to expand a query token to increase **RECALL**, then user could set expand model to **true** by configuration, default is **false**.\nFor example, user query token is \"micro\", and assume \"microwave\" and \"microscope\" are in the index, then is user choose expand the query token \"micro\" to increase **RECALL**, both \"microwave\" and \"microscope\" will be returned and search in the index.\nThe query results from expanded tokens are penalized because they are not exactly the same as the query token.\n```javascript\nindex.search(\"micro\", {\n    fields: {\n        title: {boost: 2, bool: \"AND\"},\n        body: {boost: 1}\n    },\n    bool: \"OR\",\n    expand: true\n});\n```\n\nField level expand configuration will overwrite global expand configuration.\n```javascript\nindex.search(\"micro\", {\n    fields: {\n        title: {\n            boost: 2,\n            bool: \"AND\",\n            expand: false\n        },\n        body: {boost: 1}\n    },\n    bool: \"OR\",\n    expand: true\n});\n```\n\n## 6. Add customized stop words\n\nElasticlunr.js contains some default stop words of English, such as:\n* a\n* about\n* an\n* all\n* also\n* and\n* any\n* but\n* the\n* ...\n\nDefaultly elasticlunr.js contains **120** stop words, user could decide not use these default stop words or add customized stop words.\n\n### 6.1 Remove default stop words\n\nYou could remove default stop words simply as:\n```javascript\nelasticlunr.clearStopWords();\n```\n\n### 6.2 Add customized stop words\n\nUser could add a list of customized stop words.\n```javascript\nvar customized_stop_words = ['an', 'hello', 'xyzabc'];\nelasticlunr.addStopWords(customized_stop_words);\n```\n\n## 7. Use elasticlunr in Node.js\n\nElasticlunr support Node.js, you could use elastilunr in node.js as a node-module.\n\nInstall elasticlunr by:\n```javascript\nnpm install elasticlunr\n```\n\nthen in your node.js project or in node.js console:\n```javascript\nvar elasticlunr = require('elasticlunr');\n\nvar index = elasticlunr(function () {\n    this.addField('title')\n    this.addField('body')\n});\n\nvar doc1 = {\n    \"id\": 1,\n    \"title\": \"Oracle released its latest database Oracle 12g\",\n    \"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.\"\n}\n\nvar doc2 = {\n    \"id\": 2,\n    \"title\": \"Oracle released its profit report of 2015\",\n    \"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.\"\n}\n\nindex.addDoc(doc1);\nindex.addDoc(doc2);\n\nindex.search(\"Oracle database profit\");\n```\n\n## 8. Save & Load Index\n\nYou just need to build index only one time offline, and then save the index to a JSON file, for future usage, you just need to load the index file.\n\nSave the index to JSON file as followings:\n```javascript\nvar elasticlunr = require('./elasticlunr.js'),\n    fs = require('fs');\n\nvar idx = elasticlunr(function () {\n  this.setRef('id');\n\n  this.addField('title');\n  this.addField('tags');\n  this.addField('body');\n});\n\nfs.readFile('./example/example_data.json', function (err, data) {\n  if (err) throw err;\n\n  var raw = JSON.parse(data);\n\n  var questions = raw.questions.map(function (q) {\n    return {\n      id: q.question_id,\n      title: q.title,\n      body: q.body,\n      tags: q.tags.join(' ')\n    };\n  });\n\n  questions.forEach(function (question) {\n    idx.addDoc(question);\n  });\n\n  fs.writeFile('./example/example_index.json', JSON.stringify(idx), function (err) {\n    if (err) throw err;\n    console.log('done');\n  });\n});\n```\n\nThe above code is the example index builder usage in [elasticlunr online example](http://elasticlunr.com/example/index.html), you only need to pay attention to:\n```javascript\n  fs.writeFile('./example/example_index.json', JSON.stringify(idx), function (err) {\n    if (err) throw err;\n    console.log('done');\n  });\n```\n\nThe function of <code>elasticlunr.Index.prototype.toJSON</code> is called in <code>JSON.stringify(idx)</code>.\n\nIf you want load an alreay persisted index file, you could use:\n```javascript\n  var indexDump = JSON.parse(indexDump)\n  console.time('load')\n  window.idx = elasticlunr.Index.load(indexDump)\n```\n\n<code>indexDump</code> is a file content, other your could load archived JSON index as whatever way you like. I'm not familiar with Javascript, so you are welcome to update this document to provide detailed example.\n\n# Other Languages\n\nDefault 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](https://github.com/weixsong/lunr-languages).\n\n## Other languages example in Browser\nSuppose you are using **elasticlunr.js** in browser for other languages, you could download the corresponding language support from [lunr-languages](https://github.com/weixsong/lunr-languages), then include the scripts as:\n```html\n<script src=\"lunr.stemmer.support.js\"></script>\n<script src=\"lunr.de.js\"></script>\n```\n\nthen, you could use elasticlunr.js as normal:\n```javascript\nvar index = elasticlunr(function () {\n    // use the language (de)\n    this.use(elasticlunr.de);\n    // then, the normal elasticlunr index initialization\n    this.addField('title')\n    this.addField('body')\n});\n```\n\nPay attention to the special code:\n```javascript\n    this.use(elasticlunr.de);\n```\n\nIf you are using other language, such as **es**(Spanish), download the corresponding <code>lunr.es.js</code> file and <code>lunr.stemmer.support.js</code>, and change the above line to:\n```javascript\n    this.use(elasticlunr.es);\n```\n\n## Other languages example in Node.js\nSuppose you are using **elasticlunr.js** in **Node.js** for other languages, you can download the corresponding language support from [lunr-languages](https://github.com/weixsong/lunr-languages), put the files <code>lunr.es.js</code> file and <code>lunr.stemmer.support.js</code> in your project, then in your **Node.js** module, use **elasticlunr.js** as:\n\n```javascript\nvar elasticlunr = require('elasticlunr');\nrequire('./lunr.stemmer.support.js')(elasticlunr);\nrequire('./lunr.de.js')(elasticlunr);\n\nvar index = elasticlunr(function () {\n    // use the language (de)\n    this.use(elasticlunr.de);\n    // then, the normal elasticlunr index initialization\n    this.addField('title')\n    this.addField('body')\n});\n```\n\nFor more details, please go to [lunr-languages](https://github.com/weixsong/lunr-languages).\n\n# Contributing\n\nSee the [`CONTRIBUTING.mdown` file](CONTRIBUTING.mdown).\n","readmeFilename":"README.md"}