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.

Advanced querying

If you want to build more expressive queries, such as then you need to set the QueryParser 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

Query Meaning
West West must appear in the text.
doc* Words that starts with doc must appear in the text.
west & wing The words west and wing must appear in the text
west wing 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.
"notr* dam*" 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 "west wing" is different - this indicates that the words should appear in sequence - the previous searches only enforce that the words appear somewhere in the text.)

Longer queries

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:
  1. Positional operators (~, ~> and >>)
  2. And (&)
  3. Or (|)

This means that west & wing | oval office would search for items containing both west and wing, or items containing oval and office.

You can specify your own precedence by using brackets
This means that you could write west & (wing | oval) & office to seach for items containing west and office and either wing or oval.

Last edited Jan 4, 2011 at 6:29 PM by MikeGoatly, version 1


No comments yet.