A bit like Solr, but much smaller and not as bright http://lunrjs.com

Oliver Nightingale 1de33989b7 Build version 2.3.2 2 days ago
build c985efc617 Upgrade dependencies 2 months ago
lib cc025bacbe Fix term presence query parsing bug 2 days ago
perf 64f4179689 Stop calculating similarity score unnecessarily 3 months ago
test cc025bacbe Fix term presence query parsing bug 2 days ago
.eslintrc.json d159dc5c11 Add more words for the spellchecker to ignore 3 weeks ago
.gitignore 45db4234a3 Update gitignore 3 months ago
.travis.yml 984c7a9be4 Build and upload docs as part of travis build 1 year ago
CHANGELOG.md 1de33989b7 Build version 2.3.2 2 days ago
CNAME 390f70a37d add cname 5 years ago
CONTRIBUTING.md 4c51464650 Switch from mdown to md for markdown file ext 10 months ago
LICENSE 2bc89f0a72 add a license 5 years ago
Makefile ab6c75f73f Expose test server on remote hosts 3 months ago
README.md f4f25aecbf Fix broken links to .md files. 8 months ago
VERSION 1de33989b7 Build version 2.3.2 2 days ago
index.html 8a98a39cf7 Update link for augment.js 3 years ago
lunr.js 1de33989b7 Build version 2.3.2 2 days ago
notes 3dd2e15b5f initial commit 6 years ago
package.json 1de33989b7 Build version 2.3.2 2 days ago
styles.css 9e809872c3 Show correct devtools link based on the browser. 4 years ago

README.md

Lunr.js

Build Status

A bit like Solr, but much smaller and not as bright.

Example

A very simple search index can be created using the following:

var idx = lunr(function () {
  this.field('title')
  this.field('body')

  this.add({
    "title": "Twelfth-Night",
    "body": "If music be the food of love, play on: Give me excess of it…",
    "author": "William Shakespeare",
    "id": "1"
  })
})

Then searching is as simple:

idx.search("love")

This returns a list of matching documents with a score of how closely they match the search query as well as any associated metadata about the match:

[
  {
    "ref": "1",
    "score": 0.3535533905932737,
    "matchData": {
      "metadata": {
        "love": {
          "body": {}
        }
      }
    }
  }
]

API documentation is available, as well as a full working example.

Description

Lunr.js is a small, full-text search library for use in the browser. It indexes JSON documents and provides a simple search interface for retrieving documents that best match text queries.

Why

For web applications with all their data already sitting in the client, it makes sense to be able to search that data on the client too. It saves adding extra, compacted services on the server. A local search index will be quicker, there is no network overhead, and will remain available and useable even without a network connection.

Installation

Simply include the lunr.js source file in the page that you want to use it. Lunr.js is supported in all modern browsers.

Alternatively an npm package is also available npm install lunr.

Browsers that do not support ES5 will require a JavaScript shim for Lunr to work. You can either use Augment.js, ES5-Shim or any library that patches old browsers to provide an ES5 compatible JavaScript environment.

Contributing

See the CONTRIBUTING.md file.