1
public void index(IndexItem indexItem) throws IOException {
writer.deleteDocuments(new Term(IndexItem.ID,indexItem.getId().toString()));
Document doc = new Document();
// doc.add(new LongField(IndexItem.ID, indexItem.getId(), Field.Store.YES));
doc.add(new TextField(IndexItem.CONTENT, indexItem.getContent(), Field.Store.NO));
doc.add(new StringField(IndexItem.PATH, indexItem.getPath(), Field.Store.YES));
// add the document to the index
writer.addDocument(doc, analyzer);
writer.updateDocument(new Term(IndexItem.CONTENT, indexItem.getContent().toString()), doc);
System.out.println(indexItem.getTitle());
writer.close();
}
여기 Writer.deleteDocuments가 작동하지 않습니다. 따라서 파일을 색인 할 때마다 기존 파일을 삭제하지 않고 새로운 파일을 만듭니다. 단지 사본을 만듭니다.IndexWriter deleteDocuments 함수가 작동하지 않습니다.
이 무엇인가하는 것은
오, 죄송합니다. 입력상의 실수였습니다. 오류가 해결되었습니다. 귀하의 회신에 감사드립니다. –
@myk. 어떻게 그걸 해결 했니? 나는 비슷한 문제가있다. –