private static void buildIndex(bool buildVerbose)
 {
     try
     {
         string[] si = MyIndex.GetAllIndexDirectory();
         Stopwatch sw = new Stopwatch();
         CleanIndexIfApplicable();
         SearchAutoComplete searchIndex = null;
         bool flagFirstTime = true;
         if (si != null && si.Length > 0)
         {
             foreach (string directory in si)
             {
                 if (directory != null)
                 {
                     searchIndex = new SearchAutoComplete(directory);
                     searchIndex.IsFirstTime = flagFirstTime;
                     System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(directory);
                     if (di.Exists)
                     {
                         log.Info(string.Format("Index in directory {0} is building now...", di.Name));
                         FSDirectory fsd = FSDirectory.Open(di);
                         Lucene.Net.Index.CheckIndex ci = new CheckIndex(fsd);
                         Lucene.Net.Index.CheckIndex.Status st = ci.CheckIndex_Renamed_Method();
                         if (st.clean)
                         {
                             sw.Start();
                             searchIndex.BuildAutoCompleteIndex(fsd, MyIndex.GetAutoUpdateIndexDirectory(), buildVerbose);
                             sw.Stop();
                             TimeSpan ts = sw.Elapsed;
                             string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
                             log.Info(string.Format("Time taken {0} to build this index {1}", elapsedTime, di.Name));
                             flagFirstTime = false;
                         }
                         else
                         {
                             log.Info(string.Format("Following Index named {0} is corrupted, please rebuild that index using Sitecore Rebuild Index Wizard", di.Name));
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("Error Occurred during buildIndex().", ex);
     }
 }
        private static string[] searchTerm(string term)
        {
            string[] suggestions = null;

            if (term != null && term.Length > 1)
            {
                try
                {
                    SearchAutoComplete searchIndex1 = new SearchAutoComplete(MyIndex.GetAutoUpdateIndexDirectory());
                    suggestions = searchIndex1.SuggestTermsFor(term);
                    if (suggestions != null && suggestions.Length > 1)
                        suggestions = suggestions.Distinct().ToArray<string>();
                }
                catch (Exception ex)
                {
                    log.Error("Error Occurred during searchTerm() and term is " + term + ". ", ex);
                }
            }
            return suggestions;
        }