Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
 public static void ClearInstance()
 {
     if (_instance != null)
     {
         _instance.Dispose();
         _instance = null;
     }
     _instance = new LuceneController();
 }
Ejemplo n.º 3
0
 private void Update(LuceneIndexItem data, LuceneController storeInstance)
 {
     if (null == data)
     {
         throw new ArgumentNullException("data");
     }
     Delete(data, storeInstance);
     Add(data, storeInstance);
 }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 private void IndexClear()
 {
     LuceneController.ClearInstance();
     try
     {
         using (var lc = LuceneController.Instance)
         {
             lc.Store.DeleteAll();
         }
     }
     finally
     {
         LuceneController.ClearInstance();
     }
 }
Ejemplo n.º 7
0
        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);
            }
        }