/// <summary> /// Reindex all OpenContent modules of all portals. /// </summary> internal void IndexAll() { Log.Logger.Info("Reindexing all OpenContent data, from all portals"); LuceneController.ClearInstance(); try { using (var lc = LuceneController.Instance) { ModuleController mc = new ModuleController(); foreach (PortalInfo portal in PortalController.Instance.GetPortals()) { var modules = DnnUtils.GetDnnOpenContentModules(portal.PortalID); foreach (var module in modules) { IndexModule(lc, module); } } lc.Store.Commit(); lc.Store.OptimizeSearchIndex(true); } } catch (Exception ex) { Log.Logger.Error("Error while Reindexing all OpenContent data, from all portals", ex); } finally { LuceneController.ClearInstance(); } Log.Logger.Info("Finished Reindexing all OpenContent data, from all portals"); }
private void IndexModuleData(LuceneController lc, int moduleId, OpenContentSettings settings) { bool index = false; if (settings.TemplateAvailable) { index = settings.Manifest.Index; } FieldConfig indexConfig = null; if (index) { indexConfig = OpenContentUtils.GetIndexConfig(settings.Template.Key.TemplateDir); } if (settings.IsOtherModule) { moduleId = settings.ModuleId; } lc.Store.Delete(new TermQuery(new Term("$type", moduleId.ToString()))); OpenContentController occ = new OpenContentController(); foreach (var item in occ.GetContents(moduleId)) { lc.Add(item, indexConfig); } }
/// <summary> /// Reindex all OpenContent modules of all portals. /// </summary> internal void IndexAll() { Log.Logger.Info("Reindexing all OpenContent data, from all portals"); LuceneController.ClearInstance(); try { using (var lc = LuceneController.Instance) { ModuleController mc = new ModuleController(); foreach (PortalInfo portal in PortalController.Instance.GetPortals()) { ArrayList modules = mc.GetModulesByDefinition(portal.PortalID, AppConfig.OPENCONTENT); foreach (ModuleInfo module in modules.OfType <ModuleInfo>()) { IndexModule(lc, module); } } lc.Store.Commit(); lc.Store.OptimizeSearchIndex(true); } } catch (Exception ex) { Log.Logger.Error("Error while Reindexing all OpenContent data, from all portals", ex); } finally { LuceneController.ClearInstance(); } Log.Logger.Info("Finished Reindexing all OpenContent data, from all portals"); }
private void IndexModuleData(LuceneController lc, int moduleId, OpenContentSettings settings) { bool index = false; if (settings.TemplateAvailable) { index = settings.Manifest.Index; } FieldConfig indexConfig = null; if (index) { indexConfig = OpenContentUtils.GetIndexConfig(settings.Template); } if (settings.IsOtherModule) { moduleId = settings.ModuleId; } lc.Store.Delete(new TermQuery(new Term("$type", OpenContentInfo.GetScope(moduleId, settings.Template.Collection)))); OpenContentController occ = new OpenContentController(PortalSettings.Current.PortalId); foreach (var item in occ.GetContents(moduleId, settings.Template.Collection)) { lc.Add(item, indexConfig); } }
public static void ClearInstance() { if (_instance != null) { _instance.Dispose(); _instance = null; } _instance = new LuceneController(); }
private void IndexModule(LuceneController lc, OpenContentModuleInfo module) { OpenContentUtils.CheckOpenContentSettings(module); if (module.IsListMode() && !module.Settings.IsOtherModule) { IndexModuleData(lc, module.ViewModule.ModuleID, module.Settings); } }
private void IndexModule(LuceneController lc, ModuleInfo module) { OpenContentSettings settings = new OpenContentSettings(module.ModuleSettings); OpenContentUtils.CheckOpenContentSettings(module, settings); if (settings.IsListTemplate() && !settings.IsOtherModule) { IndexModuleData(lc, module.ModuleID, settings); } }
public void ReIndexModuleData(int moduleId, OpenContentSettings settings) { try { using (LuceneController lc = LuceneController.Instance) { IndexModuleData(lc, moduleId, settings); lc.Store.Commit(); lc.Store.OptimizeSearchIndex(true); } } finally { LuceneController.ClearInstance(); } }
private static void RegisterModuleDataForIndexing(LuceneController lc, OpenContentModuleConfig module) { var indexableData = GetModuleIndexableData(module); var dataExample = indexableData?.ToList().FirstOrDefault(); if (dataExample == null) { return; } var indexConfig = OpenContentUtils.GetIndexConfig(module.Settings.Template); //todo index is being build from schema & options. But they should be provided by the provider, not directly from the files string scope = dataExample.GetScope(); lc.AddList(indexableData, indexConfig, scope); }
/// <summary> /// A method to Register all indexable data. This is used by IndexAll() /// </summary> private static void RegisterAllIndexableData(LuceneController lc) { App.Services.Logger.Info("Start Reindexing all OpenContent Data"); foreach (PortalInfo portal in PortalController.Instance.GetPortals()) { var modules = DnnUtils.GetDnnOpenContentModules(portal.PortalID); foreach (var module in modules) { if (!OpenContentUtils.CheckOpenContentTemplateFiles(module)) { continue; } if (module.IsListMode() && module.Settings.Manifest.Index) { RegisterModuleDataForIndexing(lc, module); } } } App.Services.Logger.Info("Finished Reindexing all OpenContent Data"); }
/// <summary> /// Use this to /// </summary> /// <param name="list">The list.</param> /// <param name="indexConfig">The index configuration.</param> /// <param name="scope">The scope.</param> public void ReIndexData(IEnumerable <IIndexableItem> list, FieldConfig indexConfig, string scope) { try { using (var lc = LuceneController.Instance) { DeleteAllOfType(lc, scope); foreach (IIndexableItem item in list) { lc.Add(item, indexConfig); } lc.Store.Commit(); lc.Store.OptimizeSearchIndex(true); } } finally { LuceneController.ClearInstance(); } }
/// <summary> /// Use this to /// </summary> /// <param name="list">The list.</param> /// <param name="indexConfig">The index configuration.</param> /// <param name="scope">The scope.</param> public void ReIndexModuleData(IEnumerable <IIndexableItem> list, FieldConfig indexConfig, string scope) { try { using (LuceneController lc = LuceneController.Instance) { lc.Store.Delete(new TermQuery(new Term("$type", scope))); foreach (var item in list) { lc.Add(item, indexConfig); } lc.Store.Commit(); lc.Store.OptimizeSearchIndex(true); } } finally { LuceneController.ClearInstance(); } }
/// <summary> /// Reindex all content. /// </summary> public void IndexAll(Action <LuceneController> funcRegisterAllIndexableData) { App.Services.Logger.Info("Reindexing all OpenContent data, from all portals"); LuceneController.ClearInstance(); try { using (var lc = LuceneController.Instance) { lc.Store.DeleteAll(); funcRegisterAllIndexableData(lc); lc.Store.Commit(); lc.Store.OptimizeSearchIndex(true); } } catch (Exception ex) { App.Services.Logger.Error("Error while Reindexing all OpenContent data, from all portals", ex); } finally { LuceneController.ClearInstance(); } App.Services.Logger.Info("Finished Reindexing all OpenContent data, from all portals"); }
private static void DeleteAllOfType(LuceneController lc, string scope) { var selection = JsonMappingUtils.CreateTypeQuery(scope); lc.Store.Delete(selection); }