/** * Returns the Solr index configured with the given name.<p> * The index must exist, otherwise <code>null</code> is returned. * * @param indexName then name of the requested Solr index * @return the Solr index configured with the given name */ public CmsSolrIndex getIndexSolr(String indexName) { CmsSearchIndex index = getIndex(indexName); if (index instanceof CmsSolrIndex) { return (CmsSolrIndex)index; } return null; }
/** * Returns <code>true</code> if the index for the given name is a Lucene index, <code>false</code> otherwise.<p> * * @param indexName the name of the index to check * * @return <code>true</code> if the index for the given name is a Lucene index */ public static boolean isLuceneIndex(String indexName) { CmsSearchIndex i = OpenCms.getSearchManager().getIndex(indexName); if (i instanceof CmsSolrIndex) { return false; } return true; }
/** * Rebuilds (if required creates) the index with the given name.<p> * * @param indexName the name of the index to rebuild * @param report the report object to write messages (or <code>null</code>) * * @throws CmsException if something goes wrong */ public void rebuildIndex(String indexName, I_CmsReport report) throws CmsException { try { SEARCH_MANAGER_LOCK.lock(); // get the search index by name CmsSearchIndex index = getIndex(indexName); // update the index updateIndex(index, report, null); // clean up the extraction result cache cleanExtractionCache(); } finally { SEARCH_MANAGER_LOCK.unlock(); } }
/** * Rebuilds (if required creates) the index with the given name.<p> * * @param indexName the name of the index to rebuild * @param report the report object to write messages (or <code>null</code>) * * @throws CmsException if something goes wrong */ public synchronized void rebuildIndex(String indexName, I_CmsReport report) throws CmsException { // get the search index by name CmsSearchIndex index = getIndex(indexName); // update the index updateIndex(index, report, null); // clean up the extraction result cache cleanExtractionCache(); }
/** * Removes all indexes included in the given list (which must contain the name of an index to remove).<p> * * @param indexNames the names of the index to remove */ public void removeSearchIndexes(List<String> indexNames) { Iterator<String> i = indexNames.iterator(); while (i.hasNext()) { String indexName = i.next(); // get the search index by name CmsSearchIndex index = getIndex(indexName); if (index != null) { // remove the index removeSearchIndex(index); } else { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_NO_INDEX_WITH_NAME_1, indexName)); } } } }
/** * Removes all indexes included in the given list (which must contain the name of an index to remove).<p> * * @param indexNames the names of the index to remove */ public void removeSearchIndexes(List<String> indexNames) { Iterator<String> i = indexNames.iterator(); while (i.hasNext()) { String indexName = i.next(); // get the search index by name CmsSearchIndex index = getIndex(indexName); if (index != null) { // remove the index removeSearchIndex(index); } else { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_NO_INDEX_WITH_NAME_1, indexName)); } } } }
/** * Returns the available search indexes of this installation. * * @return the available search indexes of this installation */ private List<CmsSearchIndexSource> searchIndexSources() { CmsSearchManager manager = OpenCms.getSearchManager(); CmsSearchIndex index = manager.getIndex(getParamIndexName()); List<CmsSearchIndexSource> sources = index.getSources(); return sources; }
/** * Returns the available search indexes of this installation. * * @return the available search indexes of this installation */ private List<CmsSearchIndexSource> searchIndexSources() { CmsSearchManager manager = OpenCms.getSearchManager(); CmsSearchIndex index = manager.getIndex(getParamIndexName()); List<CmsSearchIndexSource> sources = index.getSources(); return sources; }
/** * Returns the available search indexes of this installation. * * @return the available search indexes of this installation */ private List<CmsSearchIndexSource> searchIndexSources() { CmsSearchManager manager = OpenCms.getSearchManager(); CmsSearchIndex index = manager.getIndex(getParamIndexName()); List<CmsSearchIndexSource> sources = index.getSources(); return sources; }
/** * Returns the list of searchable fields used in the workplace search index.<p> * * @return the list of searchable fields used in the workplace search index */ public List<CmsSearchField> getSearchFields() { CmsSearchIndex index = OpenCms.getSearchManager().getIndex(getParamIndexName()); List<CmsSearchField> result = new ArrayList<CmsSearchField>(); Iterator<CmsSearchField> i = index.getFieldConfiguration().getFields().iterator(); while (i.hasNext()) { CmsLuceneField field = (CmsLuceneField)i.next(); if (field.isIndexed() && field.isDisplayed()) { // only include indexed (ie. searchable) fields result.add(field); } } return result; }
/** * Rebuilds (if required creates) the List of indexes with the given name.<p> * * @param indexNames the names (String) of the index to rebuild * @param report the report object to write messages (or <code>null</code>) * * @throws CmsException if something goes wrong */ public synchronized void rebuildIndexes(List<String> indexNames, I_CmsReport report) throws CmsException { Iterator<String> i = indexNames.iterator(); while (i.hasNext()) { String indexName = i.next(); // get the search index by name CmsSearchIndex index = getIndex(indexName); if (index != null) { // update the index updateIndex(index, report, null); } else { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_NO_INDEX_WITH_NAME_1, indexName)); } } } // clean up the extraction result cache cleanExtractionCache(); }
while (itItems.hasNext()) { CmsListItem listItem = itItems.next(); searchManager.removeSearchIndex(searchManager.getIndex((String)listItem.get(LIST_COLUMN_NAME))); removedItems.add(listItem.getId());
/** * Returns the list of searchable fields used in the workplace search index.<p> * * @return the list of searchable fields used in the workplace search index */ public List getFields() { CmsSearchIndex index = OpenCms.getSearchManager().getIndex( getSettings().getUserSettings().getWorkplaceSearchIndexName()); List result = new ArrayList(); Iterator i = index.getFieldConfiguration().getFields().iterator(); while (i.hasNext()) { CmsSearchField field = (CmsSearchField)i.next(); if (field.isIndexed() && field.isDisplayed()) { // only include indexed (ie. searchable) fields result.add(field); } } return result; }
/** * Initializes the user object to work with depending on the dialog state and request parameters.<p> * * Two initializations of the user object on first dialog call are possible: * <ul> * <li>edit an existing search index</li> * <li>create a new search index with default initialization</li> * </ul> */ protected void initUserObject() { try { m_index = m_searchManager.getIndex(getParamIndexName()); if (m_index == null) { m_index = createDummySearchIndex(); } } catch (Exception e) { m_index = createDummySearchIndex(); } }
/** Gets the index to use in the search. * * @return the index to use in the search */ private CmsSearchIndex getIndex() { CmsSearchIndex index = null; // get the configured index or the selected index if (isInitialCall()) { // the search form is in the initial state // get the configured index index = OpenCms.getSearchManager().getIndex(getSettings().getUserSettings().getWorkplaceSearchIndexName()); } else { // the search form is not in the inital state, the submit button was used already or the // search index was changed already // get the selected index in the search dialog index = OpenCms.getSearchManager().getIndex(getJsp().getRequest().getParameter("indexName.0")); } return index; }
/** * Sets the rebuild mode for the requested index. Allowing to disable indexing during module import.<p> * This setting will not be written to the XML configuration file and will only take effect within the current shell instance.<p> * * @param searchIndex the search index * @param mode the rebuild mode to set */ public void setIndexRebuildMode(String searchIndex, String mode) { CmsSearchIndex index = OpenCms.getSearchManager().getIndex(searchIndex); if (index != null) { index.setRebuildMode(mode); // required for this setting to take effect OpenCms.getSearchManager().initOfflineIndexes(); } }
/** * Set the name of the index to search.<p> * * @param indexName the name of the index */ public void setIndex(String indexName) { CmsSearchIndex index; if (CmsStringUtil.isNotEmpty(indexName)) { try { index = OpenCms.getSearchManager().getIndex(indexName); if (index == null) { throw new CmsException(Messages.get().container(Messages.ERR_INDEX_NOT_FOUND_1, indexName)); } setSearchIndex(index); } catch (Exception exc) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INDEX_ACCESS_FAILED_1, indexName), exc); } } } }
/** * Set the name of the index to search.<p> * * * @param indexName the name of the index */ public void setIndex(String indexName) { CmsSearchIndex index; if (CmsStringUtil.isNotEmpty(indexName)) { try { index = OpenCms.getSearchManager().getIndex(indexName); if (index == null) { throw new CmsException(Messages.get().container(Messages.ERR_INDEX_NOT_FOUND_1, indexName)); } setSearchIndex(index); } catch (Exception exc) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INDEX_ACCESS_FAILED_1, indexName), exc); } } } }
/** * Set the name of the index to search.<p> * * A former search result will be deleted.<p> * * @param indexName the name of the index */ public void setIndex(String indexName) { resetLastResult(); if (CmsStringUtil.isNotEmpty(indexName)) { try { CmsSearchIndex index = OpenCms.getSearchManager().getIndex(indexName); if (index == null) { throw new CmsException(Messages.get().container(Messages.ERR_INDEX_NOT_FOUND_1, indexName)); } m_parameters.setSearchIndex(index); } catch (Exception exc) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_INDEX_ACCESS_FAILED_1, indexName), exc); } m_lastException = exc; } } }
/** * Set the name of the index to search.<p> * * A former search result will be deleted.<p> * * @param indexName the name of the index */ public void setIndex(String indexName) { resetLastResult(); CmsSearchIndex index; if (CmsStringUtil.isNotEmpty(indexName)) { try { index = OpenCms.getSearchManager().getIndex(indexName); if (index == null) { throw new CmsException(Messages.get().container(Messages.ERR_INDEX_NOT_FOUND_1, indexName)); } m_parameters.setSearchIndex(index); } catch (Exception exc) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_INDEX_ACCESS_FAILED_1, indexName), exc); } m_lastException = exc; } } }