Nomadic People Migration
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    cn-searchpublic

    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 

    install

    npm i cn-search

    Downloadslast 7 days

    3

    version

    1.0.0

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar