0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-03-04 02:02:39 -05:00
verdaccio/node_modules/lunr
2014-11-25 03:08:06 +03:00
..
build bundle all the deps 2014-11-25 03:08:06 +03:00
docs bundle all the deps 2014-11-25 03:08:06 +03:00
example bundle all the deps 2014-11-25 03:08:06 +03:00
lib bundle all the deps 2014-11-25 03:08:06 +03:00
out bundle all the deps 2014-11-25 03:08:06 +03:00
perf bundle all the deps 2014-11-25 03:08:06 +03:00
test bundle all the deps 2014-11-25 03:08:06 +03:00
.npmignore bundle all the deps 2014-11-25 03:08:06 +03:00
.travis.yml bundle all the deps 2014-11-25 03:08:06 +03:00
bower.json bundle all the deps 2014-11-25 03:08:06 +03:00
CHANGELOG.mdown bundle all the deps 2014-11-25 03:08:06 +03:00
CNAME bundle all the deps 2014-11-25 03:08:06 +03:00
component.json bundle all the deps 2014-11-25 03:08:06 +03:00
CONTRIBUTING.mdown bundle all the deps 2014-11-25 03:08:06 +03:00
index.html bundle all the deps 2014-11-25 03:08:06 +03:00
LICENSE bundle all the deps 2014-11-25 03:08:06 +03:00
lunr.js bundle all the deps 2014-11-25 03:08:06 +03:00
lunr.min.js bundle all the deps 2014-11-25 03:08:06 +03:00
Makefile bundle all the deps 2014-11-25 03:08:06 +03:00
notes bundle all the deps 2014-11-25 03:08:06 +03:00
package.json bundle all the deps 2014-11-25 03:08:06 +03:00
README.mdown bundle all the deps 2014-11-25 03:08:06 +03:00
server.js bundle all the deps 2014-11-25 03:08:06 +03:00
styles.css bundle all the deps 2014-11-25 03:08:06 +03:00
VERSION bundle all the deps 2014-11-25 03:08:06 +03:00

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', { boost: 10 })
    this.field('body')
})

Adding documents to be indexed is as simple as:

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

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:

[{
    "ref": 1,
    "score": 0.87533
}]

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.

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.mdown file.