Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/iinitd/racci

πŸ•ŠοΈ A lightweight search engine for Node.js, Chinese supported.
https://github.com/iinitd/racci

chinese node search

Last synced: 3 months ago
JSON representation

πŸ•ŠοΈ A lightweight search engine for Node.js, Chinese supported.

Awesome Lists containing this project

README

        

# Racci

[![npm version](https://badge.fury.io/js/racci.svg)](https://badge.fury.io/js/racci) [![Build Status](https://travis-ci.org/cogons/racci.svg?branch=master)](https://travis-ci.org/cogons/racci)

A lightweight search engine for Node.js, Chinese supported.

# Feature

- Support two search mode: full-text search and field search

- Support Chinese query

- Customize field weight in full-text search

# Usage

It is extremly simple.

### Step 1: require racci

```js
npm i racci --save

var racci = require('racci')
```

### Step 2: import corpus

```js
var docs = {
"1":{"singer":"Jay Chou",
"composer":"Jay Chou"},
"2":{"singer":"Jay Chou",
"composer":"Jay Chou"}}

// format: {identifier:[Object]}

racci.Parser.import(docs)
```

### Step 3: Build models once and for all

```js
// full-text search model
racci.Parser.init("corpus", ["lyrics", "singer", "composer", 'songwritter', 'album'], [1, 20, 3, 2, 1])

// name, search from these fields, field weight for ranking.

// field search model
racci.Parser.init("singer", ["singer","composer"], "commit_count")

// name, search from these fields, sort by this field.

```
### Step 4: Search!

```js
racci.Search.search("corpus", "ζ΅ζ˜Ÿι›¨",0,0)

// [ { doc: '1',},
// { doc: '2'} ]

// first flag: show doc details or not
// second flag: show score or not

racci.Search.search("singer", "周杰伦",0,1)

// [ { doc: '1', score: '57' },
// { doc: '2', score: '22' }]

racci.Search.search("corpus", "ζ΅ζ˜Ÿι›¨",1,0)

// [ { doc: [Object] },
// { doc: [Object] } ]

racci.Search.search("singer", "周杰伦",1,1)

// [ { doc: [Object], score: '57' },
// { doc: [Object], score: '22' }]

```

[Examples](https://github.com/cogons/racci/tree/master/examples)

# Implementation

A music search engine based on Express

[HERE](https://github.com/cogons/music-racci)