Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

cn-search

sxyizhiren8MIT1.0.0

Redis search for node.js,support chinese

redis, search, reds, segmentation, chinese, segment

readme

cn-search

Installation

  $ npm install cn-search

Example

the same to reds

usage

var searcher=require('cn-search');
var search = searcher.createSearch('pets');    
var strs = [];
strs.push('Tobi wants four dollars');
strs.push('Mustachio is a cat');
strs.push('这是一个支持中文的搜索引擎,hello man');

strs.forEach(function(str, i){ search.index(str, i); });


// search who have all words in it.
search
  .query('支持 hello')
  .end(function(err, ids){
    if (err) throw err;
    console.log('Search results for "%s":', query);
    ids.forEach(function(id){
      console.log('  - %s', strs[id]);
    });
});

// search who have either word in it.
search
    .query('中文 Mustachio')
    .type('or')
    .end(function(err, ids){
        if (err) throw err;
        console.log('Search results for "%s":', query);
        ids.forEach(function(id){
          console.log('  - %s', strs[id]);
        });
    });


// basic usage is same to reds : https://github.com/tj/reds

changelog

0.2.5 / 2013-10-05

*fork from master *use mmseg module to support chinese

0.2.4 / 2013-08-10

  • add function to limit the number of results (pagination)
  • fix failure on strings that do not contain words

0.2.3 / 2013-02-22

  • fix redis call to allow for multiple keywords

0.2.2 / 2012-10-08

  • update natural. Closes #16

0.2.1 / 2012-09-05

  • handle punctuation better [kbsymanz]

0.2.0 / 2012-08-21

  • add weighted search [kbsymanz]
  • update redis dep
  • update natural dep

0.1.4 / 2012-06-28

  • grr engines

0.1.2 / 2012-01-30

  • Upgrade natural dep. Closes #7

0.1.1 / 2011-11-16

  • Added support for node v0.5.x and v0.6.x
  • Added Query

0.1.0 / 2011-07-28

  • Added Search to allow multiple searches namespaced within Redis
  • Added web-search example
  • Added web-index example

0.0.3 / 2011-07-27

  • Added simple example
  • Changed: default reds.search() to intersection

0.0.2 / 2011-07-27

  • Added make benchmark
  • Changed: generate only a single redis client

0.0.1 / 2011-07-27

  • Initial release