红联Linux门户
Linux帮助

Lunr.js 2.1.5发布,小巧精确的JavaScript搜索引擎

发布时间:2017-12-04 09:15:55来源:红联作者:baihuo
Lunr.js 2.1.5 已发布,Lunr.js 是一个设计小巧但功能全面的 JavaScript 搜索引擎,类似 Solr。

该版本了修复导致结果元数据嵌套在搜索词下而不是字段名的 bug #320。详情

使用示例:

先创建一个非常简单的搜索索引[code]var idx = lunr(function () {
this.field('title')
this.field('body')

this.add({
"title": "Twelfth-Night",
"body": "If music be the food of love, play on: Give me excess of it…",
"author": "William Shakespeare",
"id": "1"
})
})[/code]然后[code]idx.search("love")[/code]结果返回[code][
{
"ref": "1",
"score": 0.3535533905932737,
"matchData": {
"metadata": {
"love": {
"body": {}
}
}
}
}
][/code]软件详情:https://github.com/olivernn/lunr.js

来自:开源中国社区
文章评论

共有 0 条评论