lucaong / minisearch

Tiny and powerful JavaScript full-text search engine for browser and Node
https://lucaong.github.io/minisearch/
MIT License
4.64k stars 133 forks source link

When there are a lot of markup documents (about 2000). The minisearch search search box is very sluggish, what is the solution? #259

Closed markyun closed 4 months ago

markyun commented 4 months ago

image

When there are a lot of documents (about 2000 markdown ). The minisearch search search box is very sluggish, what is the solution?

A regular search takes over 20 seconds to provide feedback on the results

当 markdown 文档非常多的时候(大约2000个)。minisearch 搜索框非常卡顿,有什么解决办法?

markyun commented 4 months ago

image

dist\assets\chunks\@localSearchIndexroot.B8e7b97W.js

lucaong commented 4 months ago

Hi @markyun , Search should never be so slow. Even with several tens of thousands of documents, a search should take millisecond. You would normally hit a bottleneck with the amount of memory used by the index long before search performance becomes a problem.

For reference, the MiniSearch demo includes around 5000 documents, and a search takes only a few milliseconds.

I suspect something is wrong with your implementation, could you provide some of your code, so I can try to help debugging your issue?

lucaong commented 4 months ago

In particular, is it possible that you are mistakenly re-indexing your documents upon each search? Indexing should only happen once (or only when documents change), and not upon each search.

Otherwise, are you using fuzzy search, and what is your fuzziness parameter? Fuzzy search is very performant, but mistakes on the amount of allowed fuzziness can make it slow (e.g. searching for a 5-character word with a fuzziness of 5 would match any 5-char word, plus any subset of the word, plus any word of up to 10 characters containing the word itself, possibly leading to a huge match list).

lucaong commented 4 months ago

@markyun I will close this issue since there is no activity, but feel free to provide more details (ideally some relevant code) and I will try to help.