flexsearch icon indicating copy to clipboard operation
flexsearch copied to clipboard

return one if exact match?

Open cellulosa opened this issue 1 year ago • 1 comments

heya thanks for the great library.

consider the following scenario:

titles to search:

  • title
  • title1

currently, if I search for titl I get both. Also If I search for title I get both, but in this instance there is an exact match. Is it possible to tweak the settings to return only the exact match, if found?

I can obviously add a logic outside of the search, but I was wondering if there is a flexsearch way of doing this.

Thanks

cellulosa avatar Jun 04 '24 19:06 cellulosa

Have you tried tokenize:"strict" while initialising the index?

Here it is in the documentation.

kunal-singh avatar Aug 09 '24 07:08 kunal-singh

Just use tokenize: "strict" within your index options. Also there is a new preset on Charset.LatinExact which will switch to case-sensitive matching.

ts-thomas avatar Mar 10 '25 18:03 ts-thomas