/** * Sets the search index to use for the search. <p> * * @param index the search index to use for the search to set. * * @throws CmsIllegalArgumentException if null is given as argument */ public void setSearchIndex(CmsSearchIndex index) throws CmsIllegalArgumentException { if (index == null) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INDEX_NULL_0)); } m_index = index; }
/** * Sets the search index to use for the search. <p> * * @param index the search index to use for the search to set. * * @throws CmsIllegalArgumentException if null is given as argument */ public void setSearchIndex(CmsSearchIndex index) throws CmsIllegalArgumentException { if (index == null) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INDEX_NULL_0)); } m_index = index; }
/** * @see org.opencms.search.I_CmsIndexWriter#close() */ public void close() throws IOException { if ((m_index != null) && LOG.isInfoEnabled()) { LOG.info( Messages.get().getBundle().key( Messages.LOG_INDEX_WRITER_MSG_CLOSE_2, m_index.getName(), m_index.getPath())); } m_indexWriter.close(); }
/** * @see org.opencms.search.I_CmsIndexWriter#commit() */ public void commit() throws IOException { if ((m_index != null) && LOG.isInfoEnabled()) { LOG.info( Messages.get().getBundle().key( Messages.LOG_INDEX_WRITER_MSG_COMMIT_2, m_index.getName(), m_index.getPath())); } m_indexWriter.commit(); }
/** * @see org.opencms.search.I_CmsSearchDocument#addSearchField(org.opencms.search.fields.CmsSearchField, java.lang.String) */ public void addSearchField(CmsSearchField field, String value) { if (field instanceof CmsLuceneField) { add(((CmsLuceneField)field).createField(value)); } else { throw (new CmsRuntimeException( Messages.get().container(Messages.LOG_INVALID_FIELD_CLASS_1, field.getClass().getName()))); } }
/** * Adds a document type.<p> * * @param documentType a document type */ public void addDocumentTypeConfig(CmsSearchDocumentType documentType) { m_documentTypeConfigs.add(documentType); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key( Messages.INIT_SEARCH_DOC_TYPES_2, documentType.getName(), documentType.getClassName())); } }
/** * Sets the timeout to abandon threads indexing a resource as a String.<p> * * @param value the timeout in milliseconds */ public void setTimeout(String value) { try { setTimeout(Long.parseLong(value)); } catch (Exception e) { LOG.error( Messages.get().getBundle().key(Messages.LOG_PARSE_TIMEOUT_FAILED_2, value, new Long(DEFAULT_TIMEOUT)), e); setTimeout(DEFAULT_TIMEOUT); } }
/** * Adds a document type.<p> * * @param documentType a document type */ public void addDocumentTypeConfig(CmsSearchDocumentType documentType) { m_documentTypeConfigs.add(documentType); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( Messages.get().getBundle().key( Messages.INIT_SEARCH_DOC_TYPES_2, documentType.getName(), documentType.getClassName())); } }
/** * Sets the maximum number of modifications before a commit in the search index is triggered as a string.<p> * * @param value the maximum number of modifications to set */ public void setMaxModificationsBeforeCommit(String value) { try { setMaxModificationsBeforeCommit(Integer.parseInt(value)); } catch (Exception e) { LOG.error(Messages.get().getBundle().key( Messages.LOG_PARSE_MAXCOMMIT_FAILED_2, value, new Integer(DEFAULT_MAX_MODIFICATIONS_BEFORE_COMMIT)), e); setMaxModificationsBeforeCommit(DEFAULT_MAX_MODIFICATIONS_BEFORE_COMMIT); } }
/** * Adds a search index source configuration.<p> * * @param searchIndexSource a search index source configuration */ public void addSearchIndexSource(CmsSearchIndexSource searchIndexSource) { m_indexSources.put(searchIndexSource.getName(), searchIndexSource); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key( Messages.INIT_SEARCH_INDEX_SOURCE_2, searchIndexSource.getName(), searchIndexSource.getIndexerClassName())); } }
/** * Shuts down the search index.<p> * * This will close the local Lucene index searcher instance.<p> * * @throws IOException in case the index could not be closed */ public void shutDown() throws IOException { if (m_searcher != null) { m_searcher.close(); } if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_INDEX_1, getName())); } }
/** * Adds a search field configuration to the search manager.<p> * * @param fieldConfiguration the search field configuration to add */ public void addFieldConfiguration(CmsSearchFieldConfiguration fieldConfiguration) { m_fieldConfigurations.put(fieldConfiguration.getName(), fieldConfiguration); if (fieldConfiguration.getFields().isEmpty()) { LOG.debug( Messages.get().getBundle().key( Messages.LOG_FIELD_CONFIGURATION_IS_EMPTY_1, fieldConfiguration.getName())); } }
/** * Adds an analyzer.<p> * * @param analyzer an analyzer */ public void addAnalyzer(CmsSearchAnalyzer analyzer) { m_analyzers.put(analyzer.getLocale(), analyzer); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( Messages.get().getBundle().key( Messages.INIT_ADD_ANALYZER_2, analyzer.getLocale(), analyzer.getClassName())); } }
/** * Adds an analyzer.<p> * * @param analyzer an analyzer */ public void addAnalyzer(CmsSearchAnalyzer analyzer) { m_analyzers.put(analyzer.getLocale(), analyzer); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key( Messages.INIT_ADD_ANALYZER_2, analyzer.getLocale(), analyzer.getClassName())); } }
/** * Removes a search index from the configuration.<p> * * @param searchIndex the search index to remove */ public void removeSearchIndex(CmsSearchIndex searchIndex) { m_indexes.remove(searchIndex); initOfflineIndexes(); if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key( Messages.LOG_REMOVE_SEARCH_INDEX_2, searchIndex.getName(), searchIndex.getProject())); } }
/** * Adds a search index source configuration.<p> * * @param searchIndexSource a search index source configuration */ public void addSearchIndexSource(CmsSearchIndexSource searchIndexSource) { m_indexSources.put(searchIndexSource.getName(), searchIndexSource); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( Messages.get().getBundle().key( Messages.INIT_SEARCH_INDEX_SOURCE_2, searchIndexSource.getName(), searchIndexSource.getIndexerClassName())); } }
/** * Closes the given Lucene index searcher.<p> * * @param searcher the searcher to close */ protected synchronized void indexSearcherClose(IndexSearcher searcher) { // in case there is an index searcher available close it if ((searcher != null) && (searcher.getIndexReader() != null)) { try { searcher.getIndexReader().close(); } catch (Exception e) { LOG.error(Messages.get().getBundle().key(Messages.ERR_INDEX_SEARCHER_CLOSE_1, getName()), e); } } }
/** * Closes the Lucene index searcher for this index.<p> * * @see #indexSearcherOpen(String) */ protected synchronized void indexSearcherClose() { // in case there is an index searcher available close it if ((m_searcher != null) && (m_searcher.getIndexReader() != null)) { try { m_searcher.getIndexReader().close(); } catch (Exception e) { LOG.error(Messages.get().getBundle().key(Messages.ERR_INDEX_SHUTDOWN_1, getName()), e); } } }
/** * @see org.opencms.search.I_CmsIndexWriter#updateDocument(java.lang.String, org.opencms.search.I_CmsSearchDocument) */ public void updateDocument(String rootPath, I_CmsSearchDocument document) throws IOException { Term pathTerm = new Term(CmsSearchField.FIELD_PATH, rootPath); if ((m_index != null) && LOG.isDebugEnabled()) { LOG.debug( Messages.get().getBundle().key( Messages.LOG_INDEX_WRITER_MSG_DOC_UPDATE_3, rootPath, m_index.getName(), m_index.getPath())); } m_indexWriter.updateDocument(pathTerm, (Document)document.getDocument()); } }
/** * @see org.opencms.search.fields.I_CmsSearchFieldMapping#setType(java.lang.String) */ public void setType(String type) { CmsSearchFieldMappingType mappingType = CmsSearchFieldMappingType.valueOf(type); if (mappingType == null) { // invalid mapping type has been used, throw an exception throw new CmsRuntimeException( new CmsMessageContainer(Messages.get(), Messages.ERR_FIELD_TYPE_UNKNOWN_1, new Object[] {type})); } setType(mappingType); }