weixsong / elasticlunr.js

Based on lunr.js, but more flexible and customized.
http://elasticlunr.com
MIT License
2.02k stars 147 forks source link

Show result for special characters in the search? #136

Closed JesusValera closed 2 years ago

JesusValera commented 2 years ago

This is a picture of a search box I have implemented.

What I want is when the user types / he get the second result (instead of forcing him to write div - the output in the picture comes from the description of the item itself).

Is it possible to allow special characters in the search, like %, *, **, +, -, =, / ...? At the moment, when someone types any of those special characters nothing happens.

image

Thank you so much.

JesusValera commented 2 years ago

Edit: I found it works only replacing the trimmer section

// from:
return token
  .replace(/^\W+/, '')
  .replace(/\W+$/, '');

// to:
return token;