private static void _addToLuceneIndex(ArchiveDocument document, IndexWriter writer) { _removeFromLuceneIndex(document, writer); // add new index entry var doc = new Document(); doc.Add(new Field("Id", document.Id, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("Name", document.Name, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field("Fulltext", document.Fulltext, Field.Store.YES, Field.Index.ANALYZED)); writer.AddDocument(doc); }
private static void _removeFromLuceneIndex(ArchiveDocument document, IndexWriter writer) { var searchQuery = new TermQuery(new Term(LUCENE_IDENTIFIER, document.Id.ToString())); writer.DeleteDocuments(searchQuery); }
/************** * Remove Document(s) **************/ public static void RemoveSingleDocumentFromIndex(ArchiveDocument doc) { RemoveMultipleDocumentsFromIndex(new List <ArchiveDocument> { doc }); }
/************** * Add Document(s) **************/ public static void AddSingleDocumentToIndex(ArchiveDocument doc) { AddMultipleDocumentsToIndex(new List <ArchiveDocument> { doc }); }