0
我有許多文檔的lucene索引。在lucene索引的所有文檔中查找一個文檔的條目
現在,我顯示所有與此代碼的文件路徑的列表:
public List<Verbatim> GetAllPath(string indexFolder)
{
FSDirectory directory = FSDirectory.Open(indexFolder);
List<string> pathlist = new List<Verbatim>();
IndexReader reader = IndexReader.Open(directory, true);
for (int i = 0; i < reader.NumDocs(); i++)
{
if (reader.IsDeleted(i))
continue;
Document doc = reader.Document(i);
pathlist.Add(doc.GetFields("path"));
}
reader.Dispose();
return termlist;
}
但現在我必須列出的文件中的條款該列表。該術語在「文本」字段中。我嘗試使用這段代碼來創建這個列表,但似乎這是不可能的。
我的字段的定義是這樣的:
doc.Add(new Field("date", DateTime.Now.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.Add(new Field("path", path, Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.Add(new Field("title", System.Web.HttpUtility.HtmlDecode(title), Field.Store.YES, Field.Index.ANALYZED));
doc.Add(new Field("text", ParseHtml(text, false), Field.Store.YES, Field.Index.ANALYZED));
如何列出一個文檔中的所有條款?