/// <summary> /// Add a new text facet label. /// </summary> /// <param name="dimensionName">The dimension name.</param> /// <param name="directoryInfo">The directory information where all the files that are to be added are located.</param> /// <param name="documents">The supported documents search filter, used to indicate what files are to be added for the dimension and path.</param> /// <param name="path">The facet paths for the dimension.</param> public void AddFacet(string dimensionName, DirectoryInfo directoryInfo, SupportedDocumentExtension documents, params string[] path) { _fileFacetFields.Add(new FacetField(dimensionName, path), new FileFacetModel(directoryInfo, documents)); }
/// <summary> /// Remove documents from the existing index. /// </summary> /// <param name="directoryIndexInfo">The directory infomation where the index files are located.</param> /// <param name="directoryInfo">The top level relative directory information where all the files that are to be removed are located.</param> /// <param name="files">The array of all files that are to be removed relative to the directory info.</param> /// <param name="documents">The supported documents search filter, used to indicate what files are to be removed.</param> public void RemoveDocuments(DirectoryInfo directoryIndexInfo, DirectoryInfo directoryInfo, string[] files, SupportedDocumentExtension documents) { Lucene.Net.Index.IndexWriter writer = null; Lucene.Net.Store.Directory directory = null; try { if (documents != null) { // Create the analyzer. SimpleAnalyzer simpleAnalyzer = new Analyzer.SimpleAnalyzer(); StandardAnalyzer standardAnalyzer = new Analyzer.StandardAnalyzer(simpleAnalyzer); // Create the index writer. directory = FSDirectory.Open(directoryIndexInfo); IndexWriterConfig indexConfig = new IndexWriterConfig(Lucene.Net.Util.LuceneVersion.LUCENE_48, standardAnalyzer); indexConfig.SetOpenMode(IndexWriterConfig.OpenMode_e.APPEND); // Open existing or create new. writer = new IndexWriter(directory, indexConfig); // Create the directory filter. DirectoryFilter filter = new DirectoryFilter(); Query[] queries = filter.RemoveDocuments(directoryInfo, files, documents); writer.DeleteDocuments(queries); // Commit the index. writer.Commit(); } } catch (Exception) { throw; } finally { if (writer != null) { writer.Dispose(); } if (directory != null) { directory.Dispose(); } } }
/// <summary> /// /// </summary> /// <param name="directoryInfo">The directory information where all the files that are to be added are located.</param> /// <param name="documents">The supported documents search filter, used to indicate what files are to be added for the dimension and path.</param> public FileFacetModel(DirectoryInfo directoryInfo, SupportedDocumentExtension documents) { DirectoryInfo = directoryInfo; Documents = documents; }