private void IndexFolder(DateTime?startDate, int portalId, string folderPath) { LuceneController.ClearInstance(); try { using (var lc = LuceneController.Instance) { var fileIndexer = new DnnFilesRepository(); if (!startDate.HasValue) { Log.Logger.InfoFormat("Reindexing documents from Portal {0} folder {1}", portalId, folderPath); } var indexSince = FixedIndexingStartDate(portalId, startDate ?? DateTime.MinValue); List <LuceneIndexItem> searchDocs = fileIndexer.GetPortalSearchDocuments(portalId, folderPath, true, indexSince).ToList(); Log.Logger.DebugFormat("Found {2} documents from Portal {0} folder {1} to index", portalId, folderPath, searchDocs.Count()); FieldConfig indexJson = FilesRepository.GetIndexConfig(portalId); foreach (LuceneIndexItem indexItem in searchDocs) { Delete(indexItem, lc); lc.Store.Add(LuceneMappingUtils.CreateLuceneDocument(indexItem, indexJson)); } Log.Logger.DebugFormat("Indexed {2} documents from Portal {0} folder {1}", portalId, folderPath, searchDocs.Count()); lc.Store.Commit(); lc.Store.OptimizeSearchIndex(true); } } finally { LuceneController.ClearInstance(); } }
public static void ClearInstance() { if (_instance != null) { _instance.Dispose(); _instance = null; } _instance = new LuceneController(); }
private void Update(LuceneIndexItem data, LuceneController storeInstance) { if (null == data) { throw new ArgumentNullException("data"); } Delete(data, storeInstance); Add(data, storeInstance); }
private void Add(LuceneIndexItem data, LuceneController storeInstance) { if (null == data) { throw new ArgumentNullException("data"); } FieldConfig indexJson = FilesRepository.GetIndexConfig(data.PortalId); Store.Add(LuceneMappingUtils.CreateLuceneDocument(data, indexJson)); }
private void DeleteFolder(int portalId, string folderPath, LuceneController storeInstance) { Query deleteQuery = LuceneMappingUtils.GetDeleteFolderQuery(portalId, folderPath); if (storeInstance == null) { Store.Delete(deleteQuery); } else { storeInstance.Store.Delete(deleteQuery); } }
private void IndexClear() { LuceneController.ClearInstance(); try { using (var lc = LuceneController.Instance) { lc.Store.DeleteAll(); } } finally { LuceneController.ClearInstance(); } }
private void Delete(LuceneIndexItem data, LuceneController storeInstance) { if (data == null) { throw new ArgumentNullException("data"); } Query deleteQuery = LuceneMappingUtils.GetDeleteQuery(data); if (storeInstance == null) { Store.Delete(deleteQuery); } else { storeInstance.Store.Delete(deleteQuery); } }