JavaScript全文搜索引擎:lunr.js
為您的客戶端應用程序提供一個簡單的全文搜索引擎。類似 Solr。示例代碼:
//定義索引 var idx = lunr(function () { this.field('title', { boost: 10 }) this.field('body') })//添加索引 var doc = { "title": "Twelfth-Night", "body": "If music be the food of love, play on: Give me excess of it…", "author": "William Shakespeare", "id": 1 }
idx.add(doc)//搜索 idx.search("love")
//返回結果 [{ "ref": 1, "score": 0.87533 }]</pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!