By default, Lunr will search terms by logical
OR; that is, for a search "foo bar", results will return if they contain "foo", "bar" or both. Due to the current way Lunr operates, using a wildcard (*) after a term may help yield a result if no comes up without it.
Using the switch filters allow the query to be limited to that group alone. As such, a search "foo" with the title filter enabled will return results with it present. All the variables below can be included within the query except for term presence (+/-).
For multiple filters, it it will have be typed manually in the search field. For example, "title:foo content:bar" will give results with the title "foo" present, content that has "bar" present or both title and content being fulfilled. To restrict the results, use term presence before it such as "+title:foo +content:bar" will look give results where both conditions are fulfilled.
The following filters are allowed:
Sometimes it is required to insist that a term is present or absent from the search as a way of filtering the results. This can be done by prefixing either a plus (+) to indicate a term must be present or a minus (-) to indicate it must be absent.
- +foo bar -baz - results must contain "foo", may contain "bar" and must not contain "baz".
- +foo +bar - this simulates a logical
ANDsearch of "foo AND bar" where both must be present.
Searching with use of wildcards are allowed by use of an asterisk (*) and can appear anywhere within the search term.
- fo* - words starting with "fo".
- *oo - words ending with "oo".
- f*o - words starting with "f" and ending with "o".
At times, the spelling of a term can be unclear. The amount of fuzziness in the results for a term can be done by appending a tilde (~) followed by a positive integer which determines the edit distance if either adding, removing, changing or transposing a character will lead to a match.
- foo~1 - matches terms that have a 1 edit distance for the term "foo"; this means that terms such as "boo", "fo" or "foot" will show up but not terms like "boot" because that requires two changes.
Terms within a query can be boosted to increase their importance during a search. This can be done by appending an caret (^) followed by a positive term.
- foo^10 bar - "foo" is given a boost of 10 times compared to the other terms.