public LuceneDbFolderRepository(string indexPath, Analyzer analyzer, bool useExistingIndex = false) { this.indexDirectory = new System.IO.DirectoryInfo(indexPath); this.analyzer = analyzer; if (useExistingIndex) { IEnumerable<Folder> existingFolders = GetFolders(); if (existingFolders.Any()) { folderIndex = existingFolders.OrderByDescending(f => f.FolderId).First().FolderId + 1; } } directoryIndexWriter = new DirectoryIndexWriter(indexDirectory, analyzer, recreateIndex: !useExistingIndex); }
public void CreateIndex(Offers newOffer) { // index location var indexLocation = new FileSystemIndexLocation(new DirectoryInfo(Server.MapPath("~/Index"))); var definition = new OfferIndexDefinition(); var task = new EntityUpdateTask <Offers>(newOffer, definition, indexLocation); task.IndexOptions.RecreateIndex = false; task.IndexOptions.OptimizeIndex = true; //IndexQueue.Instance.Queue(task); var indexWriter = new DirectoryIndexWriter(new DirectoryInfo(Server.MapPath("~/Index")), false); using (var indexService = new IndexService(indexWriter)) { task.Execute(indexService); } }
public static void BuildIndex(HttpContext ctx) { var indexPath = ctx.Server.MapPath("~/App_Data/Index"); var indexWriter = new DirectoryIndexWriter(new DirectoryInfo(indexPath), true); var documentPath = ctx.Server.MapPath("~/مستندات"); using (var indexService = new IndexService(indexWriter)) { indexService.IndexEntities( Directory.EnumerateFiles(documentPath, "*.markdown", SearchOption.AllDirectories), f => { var doc = new Document(); var name = Path.GetFileNameWithoutExtension(f); var text = File.ReadAllText(f); doc.Add(new Field("Id", name, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("Url", "~/مستندات/" + name, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("Title", name.Replace('-', ' '), Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field("Text", text, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field("Summary", MarkdownExtensions.ExtractSummary(text), Field.Store.YES, Field.Index.NOT_ANALYZED)); return(doc); }); } }
public override void Clear() { directoryIndexWriter = new DirectoryIndexWriter(indexDirectory, recreateIndex: true); directoryIndexWriter.Create(); folderIndex = 1; }