olivernn / lunr.js

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

Is there a global setting to change the default TERM PRESENCE to AND vs OR #512

Open imthenachoman opened 2 years ago

imthenachoman commented 2 years ago

From the documentation https://lunrjs.com/guides/searching.html#term-presence

By default, Lunr combines multiple terms together in a search with a logical OR. That is, a search for “foo bar” will match documents that contain “foo” or contain “bar” or contain both. This behaviour is controllable at the term level, i.e. the presence of each term in matching documents can be specified.

I understand we can change this behavior with idx.search("+foo +bar").

I am wondering if there is a setting somewhere that can make the default behavior a binary AND such that the following query uses a binary AND: idx.search("foo bar").

Related: https://github.com/olivernn/lunr.js/pull/332