NinjaDbPro db = new NinjaDbPro("FullTextIndexExampleDir", "FullTextIndexExampleDir.db");
//Licensed Mode
//db.UserName = "John Smith 101224";
//db.LicenseKey = "aousdf832jasf==";
//Set before OpenDatabase. Default storage is IsolatedStorageDatabase. Other options are:
//db.Storage = new MemoryDatabase(); //In memory database
//db.Storage = new FileDatabase();
//Open the database
db.OpenDatabase();
//Add a single property index if it doesn't already exist
if (!db.IndexExists<Quote>("QuoteTextIndex"))
db.AddFullTextIndex<Quote>("QuoteTextIndex", "QuoteText");
//Add a couple record to the database
Quote quote = new Quote();
quote.Author = "John";
quote.QuoteText = "The quick brown fox jumps over the lazy dog.";
db.Save(quote);
//Add a couple record to the database
quote = new Quote();
quote.Author = "Jane";
quote.QuoteText = "The rain in spain falls mainly on the plain.";
db.Save(quote);
//Find a quote by a phrase
var phraseQuery = db.SearchPhrase<Quote>("QuoteTextIndex", "brown fox", true);
//Lazy load the first record and write out a property
Console.WriteLine(phraseQuery[0].LazyValue.Author);
//Find a quote by any keywords
var anyQuery = db.SearchAnyKeywords<Quote>("QuoteTextIndex", "fox spain", true);
//Lazy load the second record and write out a property
Console.WriteLine(anyQuery[1].LazyValue.Author);
//Find a quote by all keywords
var allQuery = db.SearchAllKeywords<Quote>("QuoteTextIndex", "jumps dog", true);
//Lazy load the second record and write out a property
Console.WriteLine(allQuery[0].LazyValue.Author);
//Find a quote by Regex
Regex searchRegex = new Regex(@"brown\sfox");
var regexQuery = db.SearchByRegex<Quote>("QuoteTextIndex", searchRegex);
//Lazy load the second record and write out a property
Console.WriteLine(regexQuery[0].LazyValue.Author);
//Close the database
db.CloseDatabase();