简体   繁体   中英

Reset or clear Lucene indexing

At the moment I'm in the proces of writing unit tests for my lucene queries. 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)

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

But I noticed that this doesn't clear the Lucene indexes. 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 . This will override the existing 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.

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