NIHVIVO-721 Rebuild the search index every time the server starts.

This commit is contained in:
jeb228 2010-07-14 14:32:22 +00:00
parent 7717ab1626
commit a1cd3cef34

View file

@ -71,7 +71,7 @@ public class LuceneSetup implements javax.servlet.ServletContextListener {
public void contextInitialized(ServletContextEvent sce) { public void contextInitialized(ServletContextEvent sce) {
try { try {
ServletContext context = sce.getServletContext(); ServletContext context = sce.getServletContext();
log.info("**** Running " + this.getClass().getName() + ".contextInitialized()"); log.debug("**** Running " + this.getClass().getName() + ".contextInitialized()");
indexDir = getIndexDirName(); indexDir = getIndexDirName();
log.info("Directory of full text index: " + indexDir); log.info("Directory of full text index: " + indexDir);
@ -133,6 +133,9 @@ public class LuceneSetup implements javax.servlet.ServletContextListener {
new ProhibitedFromSearch(DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel)); new ProhibitedFromSearch(DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel));
log.debug("**** End of " + this.getClass().getName() + ".contextInitialized()"); log.debug("**** End of " + this.getClass().getName() + ".contextInitialized()");
// Start a rebuild each time the server starts.
builder.doIndexRebuild();
} catch (Throwable t) { } catch (Throwable t) {
log.error("***** Error setting up Lucene search *****", t); log.error("***** Error setting up Lucene search *****", t);
} }
@ -142,7 +145,7 @@ public class LuceneSetup implements javax.servlet.ServletContextListener {
* Gets run when the webApp Context gets destroyed. * Gets run when the webApp Context gets destroyed.
*/ */
public void contextDestroyed(ServletContextEvent sce) { public void contextDestroyed(ServletContextEvent sce) {
log.info("**** Running " + this.getClass().getName() + ".contextDestroyed()"); log.debug("**** Running " + this.getClass().getName() + ".contextDestroyed()");
IndexBuilder builder = (IndexBuilder) sce.getServletContext().getAttribute(IndexBuilder.class.getName()); IndexBuilder builder = (IndexBuilder) sce.getServletContext().getAttribute(IndexBuilder.class.getName());
builder.killIndexingThread(); builder.killIndexingThread();
} }