Пример #1
0
 public static void AddUpdateLuceneIndex(PDFPageModel pdf)
 {
     AddUpdateLuceneIndex(new List<PDFPageModel> { pdf });
 }
Пример #2
0
        private static void _addToLuceneIndex(PDFPageModel pdf, IndexWriter writer)
        {
            // remove older index entry
            var searchQuery = new TermQuery(new Term("Id", pdf.Id.ToString()));
            writer.DeleteDocuments(searchQuery);

            // add new index entry
            var doc = new Document();

            // add lucene fields mapped to db fields
            doc.Add(new Field("Id", pdf.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Path", pdf.Path, Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Name", pdf.Name, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("PageNum", pdf.PageNum.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Content", pdf.Content, Field.Store.YES, Field.Index.ANALYZED));
            // add entry to index
            writer.AddDocument(doc);
        }