/// <summary> /// This method will add and remove stopwords from a stoplist and verify the result /// </summary> public static void AddRemoveStopWords() { Console.WriteLine("Running AddRemoveStopWords Sample..."); try { Server server = new Server("."); server.ConnectionContext.Connect(); Console.WriteLine("Connected to '{0}' server", server.Name); Database db = new Database(server, "iFTSSampleDB1"); db.Create(); Console.WriteLine("Database '{0}' created", db.Name); string stopword1 = "goodbye"; string language1 = "English"; string stopword2 = "Auf Wiedersehen"; string language2 = "German"; string stopword3 = "1"; string language3 = "Neutral"; // Create an empty full-text stoplist FullTextStopList stoplist = new FullTextStopList(db, "sampleStoplist"); stoplist.Create(); Console.WriteLine("FullTextStoplist '{0}' created", stoplist.Name); // Add the above stopwords with their associated language to the full-text stoplist stoplist.AddStopWord(stopword1, language1); stoplist.AddStopWord(stopword2, language2); stoplist.AddStopWord(stopword3, language3); Console.WriteLine("Stopwords : '{0}', '{1}', '{2}' added to Stoplist '{3}'", stopword1, stopword2, stopword3, stoplist.Name); // Remove a stopword from the above created full-text stoplist stoplist.RemoveStopWord(stopword2, language2); Console.WriteLine("Stopword '{0}' removed from Stoplist '{1}'", stopword2, stoplist.Name); Console.WriteLine(); // Enumerate all the Stopwords in the stoplist and store them in a datatable DataTable dt = stoplist.EnumStopWords(); if (dt != null) { Console.WriteLine("Existing stopwords in the stoplist '{0}'", stoplist.Name); Console.WriteLine("StopWord : Language"); Console.WriteLine("--------------------"); foreach (DataRow dr in dt.Rows) { if (dr.IsNull("language") == false) { Console.WriteLine((string)dr["stopword"] + " : " + (string)dr["language"]); } } Console.WriteLine(); } // Drop the full-text stoplist stoplist.Drop(); Console.WriteLine("FullTextStoplist '{0}' dropped", stoplist.Name); db.Drop(); Console.WriteLine("Database '{0}' dropped", db.Name); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { Console.WriteLine("\n\n"); } }