public static void UpdateLuceneIndex(News data)
 {
     UpdateLuceneIndex(new[] { data });
 }
        private static void AddToLuceneIndex(News data, IndexWriter writer)
        {
            // remove older index entry
            var searchQuery = new TermQuery(new Term("Id", data.Id.ToString()));
            writer.DeleteDocuments(searchQuery);

            // add new index entry
            var doc = new Document();
            doc.Add(new Field("Id", data.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Title", data.Title, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("Content", data.Content, Field.Store.YES, Field.Index.ANALYZED));

            writer.AddDocument(doc);
        }
Esempio n. 3
0
 public static void UpdateLuceneIndex(News data)
 {
     UpdateLuceneIndex(new[] { data });
 }