Redis加Node.js的全文搜索引擎 Reds

码农软件 · 软件分类 · 搜索引擎 · 2019-08-27 12:58:09

软件介绍

Reds是由LearnBoost公司的TJ Holowaychuk开发的一个基于Redis的Node.js全文搜索引擎,其代码加上注释也只有300行。不得不说又是一个Redis的最佳实践,它的主要原理是通过Redis的sets数据结构将分词后的词语碎片进行存储。这里的分词仅仅是对英文按空格进行切分(中文分词就不要想了~)。

例子:
先添加几个句子到搜索引擎中建立索引

var strs = [];
strs.push('Tobi wants four dollars');
strs.push('Tobi only wants $4');
strs.push('Loki is really fat');
strs.push('Loki, Jane, and Tobi are ferrets');
strs.push('Manny is a cat');
strs.push('Luna is a cat');
strs.push('Mustachio is a cat');

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

然后在Tobi dollars这个组合进行搜索

search.query(query = 'Tobi dollars', function(err, ids){
  if (err) throw err;
  console.log('Search results for "%s":', query);
  ids.forEach(function(id){
    console.log('  - %s', strs[id]);
  });
  process.exit();
});

下面是其搜索结果

Search results for "Tobi dollars":
  - Tobi wants four dollars

介绍内容来自:http://blog.nosqlfan.com/html/2676.html

本文地址:https://codercto.com/soft/d/13280.html

决战618:探秘京东技术取胜之道

决战618:探秘京东技术取胜之道

京东集团618作战指挥中心 / 电子工业出版社 / 2017-11 / 99

《决战618:探秘京东技术取胜之道》以京东技术团队备战618为主线,集合京东数百位技术专家,对京东所有和618相关的关键技术系统进行了一次全面的梳理和总结,是京东技术体系的智慧结晶。 《决战618:探秘京东技术取胜之道》从前端的网站、移动入口到后端的结算、履约、物流、供应链等体系,系统展示了京东最新的技术成就。同时,也涵盖了京东正在充分运用大数据、人工智能等先进技术对所有技术体系架构进行整体......一起来看看 《决战618:探秘京东技术取胜之道》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具