Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

前端页面文本搜索及高亮 #4

Open
Dream4ever opened this issue May 17, 2018 · 0 comments
Open

前端页面文本搜索及高亮 #4

Dream4ever opened this issue May 17, 2018 · 0 comments
Labels
Front-end Everything you see and experience JS Javascript

Comments

@Dream4ever
Copy link
Owner

Dream4ever commented May 17, 2018

需求描述

同事之前做的电子书实现了文本搜索的功能,自己能不能实现得更优雅一些呢?之前的搜索方案,是获取后端数据库的查询结果,这样许多人同时搜索的话,服务器的压力就会很大。

自己想了想,这个搜索功能和其它业务没有耦合,那么就完全可以做成纯前端的搜索。

方案调研

两大搜索方向:官方文档 + 实例教程

关键字清单

入选方案

mark.js

排除方案

  • 2018-05-17:又看了一下之前研究的几个方向,中文不需要分词,否则一旦分词的结果和搜索的关键字刚好错位那就麻烦了。那么 lunr.js 和结巴分词就都不考虑了。

  • 2018-05-15:又看了一下 Algolia 的 收费方案,如果要上架一批电子书的话,显然很容易就会超出免费版的用量,那看来还是得找能够架设在自己服务器上的免费方案。

  • search-index:不支持中文搜索,demo 也很潦草,不好用。

  • lunr.js:中文分词没有很好的插件。

  • 结巴分词:纯前端搜索,无需分词。

  • Algolia:免费版的功能有限,无法实际应用。

应用过程

要点总结

@Dream4ever Dream4ever added Front-end Everything you see and experience JS Javascript labels May 17, 2018
@Dream4ever Dream4ever changed the title 前端页面文本搜索 前端页面文本搜索及高亮 May 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Front-end Everything you see and experience JS Javascript
Projects
None yet
Development

No branches or pull requests

1 participant