前端搜索JS库 Elasticlunr.js

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixingstudio/article/details/51312176

有Github账号的小伙伴们,帮忙点赞啦(Star)

本人写了一个JS的离线搜索库,支持Field search, 采用BM25模型进行Ranking, Ranking的算法和Elasticsearch一样的,效果比lunr.js有很高提升, 希望小伙伴们能够给与肯定,帮忙点赞。点击下面的链接哦。

Elasticlunr.js

这里写图片描述

Elasticlunr.js is a lightweight full-text search engine in Javascript for browser search and offline search. Elasticlunr.js is developed based on Lunr.js, but more flexible than lunr.js. Elasticlunr.js provides Query-Time boosting and field search. Elasticlunr.js is a bit like Solr, but much smaller and not as bright, but also provide flexible configuration and query-time boosting.

Elasticlunr.js is developed based on lunr.js, but more flexible than lunr.js. The main featues are as followings:

  1. Query-Time boosting, you don’t need to setup boosting weight in index building procedure, this make it more flexible that you could try different boosting scheme.
  2. More rational scoring mechanism, Elasticlunr.js use quite the same scoring mechanism as Elasticsearch, and also this scoring mechanism is used by lucene.
  3. Field-search, you could choose which field to index and which field to search.
  4. Boolean Model, you could set which field to search and the boolean model for each query token, such as “OR”, “AND”.
  5. Combined Boolean Model, TF/IDF Model and the Vector Space Model, make the results ranking more reliable.
  6. Fast, Elasticlunr.js removed TokenCorpus and Vector from lunr.js, by using combined model there is need to compute the vector of a document to compute the score of a document, this improve the search speed significantly.
  7. Small index file, Elasticlunr.js did not store TokenCorpus because there is no need to compute query vector and document vector, then the index file is very small, this is especially helpful when elasticlunr.js is used as offline search.

Why You Need Lightweight Offline Search?

  1. In some system, you don’t want to deploy any complex full-text search engine(such as Lucence, Elasticsearch, Sphinx, etc.), you only want to provide some static web pages and provide search functionality , then you could build index in previous and load index in client side(such as Browser).
    Provide offline search functionality. For some documents, user usually download these documents, you could build index and put index in the documents package, then provide offline search functionality.
  2. For some limited or restricted network, such WAN or LAN, offline search is a better choice.
    For mobile device, Iphone or Android phone, network traffic maybe very expensive, then provide offline search is a good choice.
  3. If you want to provide search functionality in your Node.js system, and you don’t want to use a complex system, or you only need to support thousands of documents, then Elasticlunr.js is what you want to use.

猜你喜欢

转载自blog.csdn.net/weixingstudio/article/details/51312176