MCPcopy Index your code
hub / github.com/olivernn/lunr.js

github.com/olivernn/lunr.js @v2.3.9

repository ↗ · DeepWiki ↗ · release v2.3.9 ↗ · + Follow
369 symbols 775 edges 52 files 103 documented · 28% updated 1y ago★ 9,204105 open issues
README

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')
  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 as:

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 usable 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.

Features

  • Full text search support for 14 languages
  • Boost terms at query time or boost entire documents at index time
  • Scope searches to specific fields
  • Fuzzy term matching with wildcards or edit distance

Contributing

See the CONTRIBUTING.md file.

Core symbols most depended-on inside this repo

suite
called by 273
perf/perf_helper.js
fn
called by 40
test/pipeline_test.js
assertions
called by 34
test/search_test.js
done
called by 27
test/env/mocha.js
parse
called by 26
test/query_parser_test.js
write
called by 22
test/env/mocha.js
quote
called by 22
test/env/mocha.js
checkOffset
called by 18
test/env/mocha.js

Shape

Function 369

Languages

TypeScript100%

Modules by API surface

test/env/mocha.js279 symbols
test/env/chai.js65 symbols
test/pipeline_test.js5 symbols
test/builder_test.js3 symbols
perf/pipeline_perf.js3 symbols
lunr.js2 symbols
test/vector_test.js1 symbols
test/utils_test.js1 symbols
test/trimmer_test.js1 symbols
test/tokenizer_test.js1 symbols
test/test_helper.js1 symbols
test/search_test.js1 symbols

Dependencies from manifests, versioned

benchmark2.1.x · 1×
chai3.5.x · 1×
eslint3.4.x · 1×
eslint-plugin-spellcheck0.0.8 · 1×
jsdoc3.5.x · 1×
mocha3.3.x · 1×
mustache2.2.x · 1×
node-static0.7.x · 1×
uglify-js2.6.x · 1×
word-list1.0.x · 1×

For agents

$ claude mcp add lunr.js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact