예제 #1
0
        /// <summary>
        /// Update the search index with the contents of the section.
        /// </summary>
        /// <param name="section"></param>
        public static void UpdateIndexFromSection(Section section)
        {
            // Get ModuleLoader from the container. This needs to happen explicit here because
            // this is a static method
            ModuleLoader moduleLoader = ContainerAccessorUtil.GetContainer()[typeof(ModuleLoader)] as ModuleLoader;
            if (moduleLoader == null)
            {
                throw new NullReferenceException("Unable to find the ModuleLoader instance");
            }
            string indexDir = HttpContext.Current.Server.MapPath(Config.GetConfiguration()["SearchIndexDir"]);
            IndexBuilder ib = new IndexBuilder(indexDir, false);

            ModuleBase module = moduleLoader.GetModuleFromSection(section);
            if (module is ISearchable)
            {
                ib.UpdateContentFromModule(module);
            }

            ib.Close();
        }
예제 #2
0
 private void BuildIndex()
 {
     string indexDir = Context.Server.MapPath(Config.GetConfiguration()["SearchIndexDir"]);
     IndexBuilder ib = new IndexBuilder(indexDir, true);
     IList sites = base.CoreRepository.GetAll(typeof(Site));
     foreach (Site site in sites)
     {
         foreach (Node node in site.RootNodes)
         {
             try
             {
                 BuildIndexByNode(node, ib);
             }
             catch (Exception ex)
             {
                 log.Error(String.Format("Indexing contents of Node {0} - {1} failed.", node.Id, node.Title), ex);
             }
         }
     }
     ib.Close();
 }
 private void IndexContent(SearchContent searchContent, IndexAction action)
 {
     // Index
     string indexDir = Context.Server.MapPath(Config.GetConfiguration()["SearchIndexDir"]);
     IndexBuilder ib = new IndexBuilder(indexDir, false);
     switch (action)
     {
         case IndexAction.Create:
             ib.AddContent(searchContent);
             break;
         case IndexAction.Update:
             ib.UpdateContent(searchContent);
             break;
         case IndexAction.Delete:
             ib.DeleteContent(searchContent);
             break;
     }
     ib.Close();
 }