olivernn / lunr.js

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

Confusing output #376

Closed nehalist closed 5 years ago

nehalist commented 5 years ago

I've recently played around with this library; and I'm a bit confused about the outcome for a certain example, see this fiddle.

Shouldn't every given input return 1 result? Am I missing something?

Edit: allowing wildcards results in getting 1 result until "impress" and 0 results for every letter afterwards.

lucaong commented 5 years ago

@nehalist, you are using the default settings, therefore exact match is performed, not prefix match nor fuzzy match. This explains why "i", "im", "imp", "impre", "impres" all return 0 results. If you search for "im*" (prefix search), you will get one result. Also, the default settings include stemming, so "impression" and "impressions" both get stemmed to "impress". That's why those three searches all return one result. You can turn off stemming if you want.

This is a modified version of your fiddle with stemming removed and prefix search: https://jsfiddle.net/sgdofjw1/1/

I hope this helps clarifying your doubts.

nehalist commented 5 years ago

Indeed, thanks a lot!