olivernn / lunr.js

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

How do I disable or customize search operators? #521

Open Thermal-Shock opened 1 year ago

Thermal-Shock commented 1 year ago

I've inherited an mkdocs-material project which uses LunrJS for the search and I'm new to Lunr.

I see Lunr has various search operators such as wildcards, fields, etc. One of these would be colon (:) for field search.

My question is whether there is a way to disable this color(:) operator or customize the operators in general.

For example, we have "ERROR: This error ..." in our documentation. If the user searches for "ERROR This" it is found, but if the user searches for "ERROR: This" it will NOT be found. I'd like to gain more control over these operators and the separators.

I can see where I can customize the separators with "lunr.tokenizer.separator = new RegExp(...)", but what about disabling, adding, or customizing operators?

Thank you for your help.