Esempio n. 1
0
        /// <summary>
        /// 修改索引
        ///</summary>
        ///<param name="model">索引实体</param>
        ///<returns></returns>
        ///<remarks>2013-3-8 杨浩 创建</remarks>
        public void UpdateIndex(Hyt.Model.PdProductIndex model)
        {
            var term = new Term("SysNo", model.SysNo.ToString());

            CreateIndex(false);
            _writer.UpdateDocument(term, ModelToDocument(model));
            _writer.Optimize();//Optimize通常需要执行一下,否则索引文件中会有两个相同id的索引
            _writer.Close();
        }
Esempio n. 2
0
 /// <summary>
 /// 增加索引
 ///</summary>
 ///<param name="model">索引实体</param>
 ///<returns></returns>
 ///<remarks>2013-3-8 杨浩 创建</remarks>
 public void AddIndex(Hyt.Model.PdProductIndex model)
 {
     try
     {
         _modifier = new IndexModifier(IndexStorePath, new PanGuAnalyzer(), false);
         _modifier.AddDocument(ModelToDocument(model));
     }
     catch
     {
         //TODO:此处实现日志异常记录
     }
     finally
     {
         _modifier.Flush();
         _modifier.Close();
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 删除索引
 ///</summary>
 ///<param name="model">索引实体</param>
 ///<returns></returns>
 ///<remarks>2013-3-8 杨浩 创建</remarks>
 public void DeleteIndex(Hyt.Model.PdProductIndex model)
 {
     try
     {
         _modifier = new IndexModifier(IndexStorePath, new PanGuAnalyzer(), false);
         Term term = new Term("SysNo", model.SysNo.ToString());
         _modifier.DeleteDocuments(term);//删除
     }
     catch
     {
         //TODO:此处实现日志异常记录
     }
     finally
     {
         _modifier.Close();
     }
 }