/** * Shuts down the search index.<p> * * This will close the local Lucene index searcher instance.<p> */ public void shutDown() { // close the index writer if (m_indexWriter != null) { try { m_indexWriter.commit(); m_indexWriter.close(); } catch (IOException e) { LOG.error( Messages.get().getBundle().key(Messages.LOG_IO_INDEX_WRITER_CLOSE_2, getPath(), getName()), e); } } indexSearcherClose(); if (m_analyzer != null) { m_analyzer.close(); } if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_INDEX_1, getName())); } }
writer.optimize();
protected void indexDocument(Document doc) throws IOException { // write the document to the index m_writer.updateDocument(m_res.getRootPath(), doc); } }
writer.commit(); } catch (IOException e) { LOG.error(
m_indexWriter.close(); m_indexWriter = null; } catch (IOException e) {
/** * Deletes a single resource from the given index.<p> * * @param indexWriter the index to delete the resource from * @param rootPath the root path of the resource to delete */ protected void deleteResource(I_CmsIndexWriter indexWriter, String rootPath) { try { if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_DELETING_FROM_INDEX_1, rootPath)); } indexWriter.deleteDocuments(rootPath); } catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key( Messages.LOG_IO_INDEX_DOCUMENT_DELETE_2, rootPath, m_index.getName()), e); } } }
/** * Deletes a resource with the given index writer.<p> * * @param indexWriter the index writer to resource the resource with * @param resource the root path of the resource to delete */ protected void deleteResource(I_CmsIndexWriter indexWriter, CmsPublishedResource resource) { try { if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_DELETING_FROM_INDEX_1, resource.getRootPath())); } // delete all documents with this term from the index indexWriter.deleteDocument(resource); } catch (IOException e) { if (LOG.isWarnEnabled()) { LOG.warn( Messages.get().getBundle().key( Messages.LOG_IO_INDEX_DOCUMENT_DELETE_2, resource.getRootPath(), m_index.getName()), e); } } }
writer.commit(); } catch (IOException e) { if (LOG.isWarnEnabled()) {
writer.commit(); } catch (IOException e) { if (LOG.isWarnEnabled()) {
/** * Updates a resource with the given index writer and the new document provided.<p> * * @param indexWriter the index writer to update the resource with * @param rootPath the root path of the resource to update * @param doc the new document for the resource */ protected void updateResource(I_CmsIndexWriter indexWriter, String rootPath, I_CmsSearchDocument doc) { try { indexWriter.updateDocument(rootPath, doc); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn( Messages.get().getBundle().key( Messages.LOG_IO_INDEX_DOCUMENT_UPDATE_2, rootPath, m_index.getName()), e); } } } }