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(); }
private void BuildIndexByNode(Node node, IndexBuilder ib) { foreach (Section section in node.Sections) { ModuleBase module = null; try { module = base.ModuleLoader.GetModuleFromSection(section); } catch (Exception ex) { log.Error(String.Format("Unable to create Module for Section {0} - {1}.", section.Id, section.Title), ex); } if (module is ISearchable) { ISearchable searchableModule = (ISearchable)module; try { foreach (SearchContent sc in searchableModule.GetAllSearchableContent()) { ib.AddContent(sc); } } catch (Exception ex) { log.Error(String.Format("Indexing contents of Section {0} - {1} failed.", section.Id, section.Title), ex); } } } foreach (Node childNode in node.ChildNodes) { BuildIndexByNode(childNode, ib); } }