コード例 #1
0
    //根据id添加或者修改索引
    public void InsertOrUpdate <T>(T model)
    {
        var doc  = LuceneTool.CreateDoc(model);
        var term = new Term("Id", doc.Get("Id"));

        LuceneTool.GetIndexWriter(indexName).UpdateDocument(term, doc);
    }
コード例 #2
0
 //批量添加索引
 public void InsertMany <T>(IEnumerable <T> list)
 {
     foreach (var item in list)
     {
         var doc = LuceneTool.CreateDoc(item);
         LuceneTool.GetIndexWriter(indexName).AddDocument(doc);
     }
 }
コード例 #3
0
 //批量根据id添加或者修改索引
 public void InsertOrUpdateMany <T>(IEnumerable <T> list)
 {
     foreach (var item in list)
     {
         var doc  = LuceneTool.CreateDoc(item);
         var term = new Term("Id", doc.Get("Id"));
         LuceneTool.GetIndexWriter(indexName).UpdateDocument(term, doc);
     }
 }
コード例 #4
0
    //添加索引
    public void Insert <T>(T model)
    {
        var doc = LuceneTool.CreateDoc(model);

        LuceneTool.GetIndexWriter(indexName).AddDocument(doc);
    }