I am using Lucene 4.6. I created a Lucene IndexWriter(in CREATE MODE) and added documents and committed it(didnt close it). Then ran a search query and stored the results. Again I added documents to the index writer and committed it and closed it. And ran a search query on it. It gave results with new data and old data also. The old data was also present in the index. May i know the way to delete all the data from the index. Is there any way to delete all the documents at a stretch?
That would be better if you could provide us the code snippet, but it seems the issue is you are using OpenMode.CREATE
instead of OpenMode.CREATE_OR_APPEND
. In that case, each time you create the IndexWriter
object, the old data is overritten, not appended.
Also, make sure you are using the latest version. The current is v4.9.0
indexwriter.deleteall方法将删除索引中的所有文档,您可以重复使用同一索引编写器在新文档上构建INDEX并运行搜索查询,然后在需要时关闭它
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.