search-index

A persistent, network resilient, full text search library for the browser and Node.js

Github stars Tracking Chart

search-index

A network resilient, persistent full-text search library for the browser and Node.js

Gitter
npm
npm
license
Build Status
JavaScript Style Guide

Documentation

Quick start

Initialise search-index

Default method

search-index can be invoked with ES6 import or commonjs require
using either lazy loading or a callback:

// Make a new index, or open an existing one with this name
import si from 'search-index'

// "lazy load"- db may not be immediately initialized
db = si({ name: 'mySearchIndex' })

// ... or callback to be sure you have it in time
si({ name: 'myDB' }, (err, db) => {
  // db is guaranteed to be open and available
})

Script tag method

In the /dist folder there is a file called
search-index.<version>.js that can be used as a standalone in a
<script> tag. The library is then available under a global variable
called searchIndex:

<script type='text/javascript' src='./search-index.1.0.2.js'></script>
<script type='text/javascript'>
  searchIndex({ name: 'myDB' }, (err, db) => {
    // db is now available
  })
</script>

Add documents to index

// db exists in a leveldb instance if run on a server
PUT([ /* my array of objects */ ]).then(doStuff)

Search the index

// search for terms without specifing any fields
SEARCH('SCOTLAND', 'GREEN').then(result)

More examples

See the tests for more examples.

Main metrics

Overview
Name With Ownerfergiemcdowall/search-index
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2013-07-04 07:56:35
Pushed At2025-04-04 11:27:22
Last Commit At2025-04-04 10:54:24
Release Count27
Last Release Namev6.0.1 (Posted on 2025-04-04 13:26:23)
First Release Namev0.10.0 (Posted on )
用户参与
Stargazers Count1.4k
Watchers Count34
Fork Count149
Commits Count1.6k
Has Issues Enabled
Issues Count447
Issue Open Count3
Pull Requests Count146
Pull Requests Open Count2
Pull Requests Close Count24
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private