Searching the full text index
Searching the index is as easy as:
var results = index.Search("Search criteria");
By default the search criteria will be processed using an instance of the SimpleQueryParser
class. This works by returning items that have words starting with each of the search words.
If you want to build more expressive queries, such as then you need to set the
property of your full text index to an instance of LiftiQueryParser
. You'll then be able to write queries using the LIFTI query language.
The LIFTI Query Language
||West must appear in the text.
||Words that starts with doc must appear in the text.
|west & wing
||The words west and wing must appear in the text
||The words west and wing must appear in the text - the default operator is & if none is specified between search words
|west | wing
||The words west or wing must appear in the text
|west ~ wing
||west and wing must appear near to each other (within 5 words) in the text
|west ~> wing
||west must be closely followed by wing (within 5 words) in the text
|west >> wing
||west must precede wing anywhere in the text
|"the west wing"
||The words the west wing must appear in sequence in the indexed text.
||A word starting with notr must be immediately followed by a word starting with dam.
If you specify two search words in a query without a joining operator, then they will automatically be combined with an and (&) operator, so the queries
west & wing
is equivalent to west wing
. (Just to clarify, searching for
is different - this indicates that the words should appear in sequence - the previous searches only enforce that the words appear
in the text.)
Query operators can be combined, so you can write a query such as the & west & wing
to search for items that have all 3 words indexed against them.
Naturally you can mix and match operators, so "west wing" & "oval office"
would search for items with the phrases "west wing" and "oval office" indexed against them.
When combining operators you need to be aware of operator precedence. Operators will be processed in the following order:
- Positional operators (~, ~> and >>)
- And (&)
- Or (|)
This means that west & wing | oval office
would search for items containing both
, or items containing oval
You can specify your own precedence by using brackets
This means that you could write west & (wing | oval) & office
to seach for items containing
and either wing