search-index

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

Github星跟踪图

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.

主要指标

概览
名称与所有者fergiemcdowall/search-index
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2013-07-04 07:56:35
推送于2025-04-04 11:27:22
最后一次提交2025-04-04 10:54:24
发布数27
最新版本名称v6.0.1 (发布于 2025-04-04 13:26:23)
第一版名称v0.10.0 (发布于 )
用户参与
星数1.4k
关注者数34
派生数149
提交数1.6k
已启用问题?
问题数447
打开的问题数3
拉请求数146
打开的拉请求数2
关闭的拉请求数24
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?