Document doc = new Document();
Field field = new Field("Url", url, Field.Store.YES, Field.Index.NO);
doc.Add(field);
field = new Field("Id",id.ToString(),Field.Store.YES,Field.Index.UN_TOKENIZED);
doc.Add(field);
field = new Field("Title", title, Field.Store.YES, Field.Index.TOKENIZED);
doc.Add(field);
field = new Field("Time", time.ToString("yyyyMMdd"), Field.Store.YES, Field.Index.UN_TOKENIZED);
doc.Add(field);
field = new Field("Contents", content, Field.Store.YES, Field.Index.TOKENIZED);
doc.Add(field);
writer.AddDocument(doc);
int num = writer.DocCount();
return num;
Term term = new Term("Id", id.ToString());
IndexReader reader = IndexReader.Open(indexDir);
reader.DeleteDocuments(term);
reader.Close();
索引的最小单位是document,删除的最小单位也是document。
您好 问下最后解决了吗 什么原因呢 遇到同样问题