コード例 #1
0
        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();
            }
        }
コード例 #2
0
 private void IndexClear()
 {
     LuceneController.ClearInstance();
     try
     {
         using (var lc = LuceneController.Instance)
         {
             lc.Store.DeleteAll();
         }
     }
     finally
     {
         LuceneController.ClearInstance();
     }
 }