コード例 #1
0
        private static void addToLuceneIndex(Creative Data, IndexWriter writer)
        {
            var searchQuery = new TermQuery(new Term("Id", Data.Id.ToString()));
            writer.DeleteDocuments(searchQuery);

            var doc = new Document();

            doc.Add(new Field("Id", Data.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Name", Data.Name, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("Description", Data.Description, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("User", Data.User, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("Votes", Data.Votes.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));

            writer.AddDocument(doc);
        }
コード例 #2
0
 public static void AddUpdateLuceneIndex(Creative sampleData)
 {
     AddUpdateLuceneIndex(new List<Creative> { sampleData });
 }
コード例 #3
0
ファイル: CreativeController.cs プロジェクト: NixonWatt/Pohui
 public ActionResult UploadCreative(UploadedCreative uploadedCreative)
 {
     Creative newCreative = new Creative
     {
         Description = uploadedCreative.Description,
         Votes = 0,
         Name = uploadedCreative.Name,
         Tags = uploadedCreative.Tags.GetTagsFromText(),
         User = User.Identity.Name
     };
     creativeRepository.Create(newCreative);
     creativeRepository.Save();
     var user = userRepository.FindFirstBy(m => m.Login == User.Identity.Name);
     user.CreativeCount++;
     userRepository.EditCreativeCount(user);
     LuceneCreativeSearch.AddUpdateLuceneIndex(newCreative);
     foreach (var tag in newCreative.Tags)
     {
         tagRepository.Create(tag);
         LuceneTagSearch.AddUpdateLuceneIndex(tag);
     }
     tagRepository.Save();
     Chapter newChapter = new Chapter
     {
         Name = "Chapter 0",
         Content = "",
         CreativeId = newCreative.Id,
         Position = 0
     };
     chapterRepository.Create(newChapter);
     chapterRepository.Save();
     LuceneChapterSearch.AddUpdateLuceneIndex(newChapter);
     newCreative = creativeRepository.FindFirstBy(n => n.Name == newCreative.Name && n.User == newCreative.User);
     var raki = "EditCreative"+"/" + newCreative.Id.ToString();
     return RedirectToAction(raki);
 }