简体   繁体   English

重置或清除Lucene索引

[英]Reset or clear Lucene indexing

At the moment I'm in the proces of writing unit tests for my lucene queries. 目前,我正在为我的Lucene查询编写单元测试。 Therefor I create a test-database containing dummy data. 为此,我创建了一个包含虚拟数据的测试数据库。 For each test I recreate my database, so each test is started using "fresh" data. 对于每个测试,我都会重新创建数据库,因此每个测试都是使用“新”数据启动的。 Normally I just put my hbm ddl property to create(as shown below) 通常我只是将hbm ddl属性创建(如下所示)

<property name="hibernate.hbm2ddl.auto">update</property>

But I noticed that this doesn't clear the Lucene indexes. 但是我注意到这并不能清除Lucene索引。 Anyone got an idea how I can make sure that each test is run on a freshly created index? 有人知道我如何确保每个测试都在新创建的索引上运行? My temporary solution is a script the runs before each test, that will simple delete the indexing folders. 我的临时解决方案是在每次测试之前运行一个脚本,该脚本将简单地删除索引文件夹。 But since these folders are somewhere on the file system, I hoped there was a more generic/standard approach to this... any ideas? 但是由于这些文件夹位于文件系统上的某个位置,所以我希望对此有更通用/标准的方法……有什么想法吗?

You can create new IndexWriter by setting create=true . 您可以通过设置create = true来创建新的IndexWriter This will override the existing index. 这将覆盖现有索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM