galty687 / lunr.js

添加中文支持的 lunr.js。无分词版本 un-participle 分支,分词版本 participle 分支

Home Page:http://lunrjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lunr.js

Join the chat at https://gitter.im/olivernn/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.

About

添加中文支持的 lunr.js。无分词版本 un-participle 分支,分词版本 participle 分支

http://lunrjs.com

License:MIT License


Languages

Language:JavaScript 88.2%Language:HTML 9.3%Language:Shell 1.0%Language:CSS 0.8%Language:Makefile 0.7%