lucaong / minisearch

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

Prefix strategy is good for search-as-you-type ONLY for last token #90

Closed patarapolw closed 3 years ago

patarapolw commented 3 years ago

I also wrote the issue here. - https://github.com/nextapps-de/flexsearch/issues/217

Also, wouldn't it be more intuitive for people, esp. non-technical; if combineWith: 'AND' by default? (Not like lunr.js, I know.)

lucaong commented 3 years ago

Hi @patarapolw , I see what you mean. In MiniSearch, it is actually possible, by specifying a function as the prefix search option, that returns true if the term is the last one in the query:

miniSearch.search('eye ca', {
  prefix: (term, i, terms) => i === terms.length - 1
})

Regarding OR vs AND, it’s a matter of recall vs. precision. I think that higher recall is often a better default (because it’s usually easier to understand why something is in the search results, than why something is not), but it very much depends on the use case.

In general, I strive to make MiniSearch versatile enough to be a good building block for diverse use cases.

I am closing the issue for now, as I think this solves it, but definitely feel free to comment further if not.