olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.94k stars 548 forks source link

abysmally slow on search term `+*` #453

Closed dimaqq closed 4 years ago

dimaqq commented 4 years ago

index.search("+*") is really really really slow:

Screenshot 2020-04-16 at 10 44 28

I guess I just have to validate the search terms before searching, don't I?

olivernn commented 4 years ago

What are you trying to achieve with a query of +*? I'd say that kind of query would be the pathological case, certainly with the current implementation of lunr.

If you are trying to get all documents from the index, that is better done outside of lunr. It's not really designed to be a general purpose store of documents.

dimaqq commented 4 years ago

I was trying to make it work like this:

Obv., I had a small bug, and empty user input was converted into +*.

I understand that that would return entire dataset and can have some overhead, but I was surprised at just how slow it was.

So I figure, maybe there's a bug? (or maybe I just shouldn't do this)

olivernn commented 4 years ago

(or maybe I just shouldn't do this)

Yes. :)

What behaviour would you expect when entering this query? What did Lunr return?

It might be possible to intercept certain queries and return something (what though?) to improve performance, I'm not yet sold on this though.

dimaqq commented 4 years ago

At the time I used to think that should return everything. But it seems that's not entirely accurate, I think that objects that are build of only empty strings won't actually match. Anyway, feel free to close or whatever.