/// <summary> /// 生成文章索引 /// </summary> /// <param name="itemCallback"></param> public void MakeLuceneIndex(Action <Document> callback) { List <Article> list = dao.GetArticleList(); List <Document> documentList = new List <Document>(); foreach (Article item in list) { Document indexDoc = new Document(); #region 根据需要添加要被索引的数据列 indexDoc.Add(new Field("Id", string.Concat("", item.Id), Field.Store.YES, Field.Index.ANALYZED)); indexDoc.Add(new Field("Title", item.Title, Field.Store.YES, Field.Index.ANALYZED)); indexDoc.Add(new Field("Content", item.Content, Field.Store.YES, Field.Index.ANALYZED)); #endregion 根据需要添加要被索引的数据列 documentList.Add(indexDoc); LuceneManager.MakeIndex(documentList, directoryPath, callback); } }