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

case-sensitive dynamic selection during search #233

Closed nanliangwu closed 10 months ago

nanliangwu commented 10 months ago

Thank you for providing this awesome Javascript library. I wanna know if it supports case-sensitive dynamic selection during search?

lucaong commented 10 months ago

Hi @nanliangwu , thanks for your kind words :)

MiniSearch is fully capable of case sensitive search. The default is to normalize case, but if you want search to be case sensitive, the easiest option is to specify your own normalization:

const miniSearch = new MiniSearch({
  fields: [/* your fields here */],
  processTerm: (term) => term // leave terms unchanged
})

Often it helps to also enable fuzzy match (with the fuzzy option set to true or to a suitable value), so that the case-sensitive results will match with higher relevance, but the case-insensitive results are matched too.

I hope this helps!

lucaong commented 10 months ago

hi @nanliangwu , since I think that the question was answered, and there is no more activity on the issue, I will go on and close it. If your problem is not solved, feel free to comment here, and I will reopen the issue if necessary.