-
Notifications
You must be signed in to change notification settings - Fork 2
Search Syntax Using Lucene Or
Kevin Day edited this page Feb 15, 2023
·
6 revisions
This follows a boosted phrase based search process that supports wild cards.
- The wild card character
*
is supported and repesents 0 or more sequential characters, such aswor*
. - The wild card character
?
is supported and represents a single character, such aswo?d
. - The fuzzy search character
~
is supported and represents , such asroam
(which matches words likeroams
,foam
, andfoams
). - Use
+
or-
to denote mandatory or prohibited matches of a given phrase. - Use quotes to group phrases for more precise matching, such as
"word1 word2"
. - Searches are case-insensitive such that upper and lower case letters are treated as indistinguishable, except for
AND
,OR
, andNOT
special use words. - Each space separated word or phrase is automatically combined using an
OR
condition except when the following word or phrase does not have a leading+
or-
or except whenAND
is explicitly specified between words. - Explicitly add either the word
AND
(all upper-case) or the wordOR
(all upper-case) between each space separated word to override the default combining condition. - Explicitly add
NOT
(all upper-case) to exclude a word or phrase just like the-
character. - Trailing punctuation is generally ignored when matching and can be omitted (for example,
Center,
andCenter
should be treated as the same search). - Adding
^
followed by a decimal number (called a boost) to a word or phrase, such asword1^0.4 word2^5.3
allows for specifying priorties on how matching where the higher the number then the higher the priority. - The following characters may have special meaning and may need to be escaped for literal matching using the escape character
\
:+ - && || ! ( ) { } [ ] ^ " ~ * ? : / \
.
Consider the following titles:
- My Apple
- My Red Apple
- Red Apple
- Blue Apple
- My Orange
- Yellow Banana
- My red hat is covering up an apple.
Using a search of my apple
should produce:
- My Apple
- My Red Apple
- Red Apple
- Blue Apple
- My Orange
- My red hat is covering up an apple.
Using a search of my^2.0 apple^1.0
should produce:
- My Apple
- My Red Apple
- My red hat is covering up an apple.
- My Orange
- Red Apple
- Blue Apple
Using a search of "my apple"
should produce:
- My Apple
Using a search of +my apple
should produce:
- My Apple
- My Red Apple
- Red Apple
- Blue Apple
- My Orange
- My red hat is covering up an apple.
Using a search of +my +apple
should produce:
- My Apple
- My Red Apple
- My red hat is covering up an apple.
Using a search of +my -red +apple
should produce:
- My Apple
Using a search of +my +red -apple
should produce:
- no results
Using a search of +my -red -apple
should produce:
- My Orange
Using a search of -apple
should produce:
- My Orange
- Yellow Banana
Using a search of "red apple"
should produce:
- My Red Apple
- Red Apple