/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() { List<CmsListItem> result = new ArrayList<CmsListItem>(); // get content List<CmsSearchIndex> indexes = OpenCms.getSearchManager().getSearchIndexesAll(); for (CmsSearchIndex index : indexes) { CmsListItem item = getList().newItem(index.getName()); item.set(LIST_COLUMN_NAME, index.getName()); item.set(LIST_COLUMN_CONFIGURATION, index.getFieldConfiguration().getName()); item.set(LIST_COLUMN_REBUILDMODE, index.getRebuildMode()); item.set(LIST_COLUMN_PROJECT, index.getProject()); item.set(LIST_COLUMN_LOCALE, index.getLocale().toString()); result.add(item); } return result; }
index = m_indexes.get(i); index.setEnabled(true); if (index.checkConfiguration(m_adminCms)) { index.initialize(); } catch (CmsException e) { CmsLog.INIT.info(Messages.get().getBundle().key( Messages.INIT_SEARCH_INIT_FAILED_1, index.getName()), e); if (index.isEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key( Messages.INIT_INDEX_CONFIGURED_2, index.getName(), index.getProject())); } else { CmsLog.INIT.info(Messages.get().getBundle().key( Messages.INIT_INDEX_NOT_CONFIGURED_2, index.getName(), index.getProject()));
/** * Creates a "dummy" search index that is not linked to the search manager and has * a <code>null</code> name property that will be used for being filled with * the widget bean technology. <p> * * @return a "dummy" search index that is not linked to the search manager and has * a <code>null</code> name property that will be used for being filled with * the widget bean technology */ private CmsSearchIndex createDummySearchIndex() { CmsSearchIndex result = new CmsSearchIndex(); result.setLocale(Locale.ENGLISH); result.setProject("Online"); result.setRebuildMode("auto"); // find default source Map<String, CmsSearchIndexSource> sources = m_searchManager.getSearchIndexSources(); if (sources.isEmpty()) { CmsSearchIndexSource source = createDummyIndexSource(); sources.put(source.getName(), source); } result.addSourceName(sources.keySet().iterator().next()); return result; } }
/** * 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())); } }
if (!index.checkConfiguration(cms)) { cms.getRequestContext().setCurrentProject(cms.readProject(index.getProject())); if (CmsSearchIndex.REBUILD_MODE_OFFLINE.equals(index.getRebuildMode())) { index.setRebuildMode(CmsSearchIndex.REBUILD_MODE_MANUAL); String backup = index.createIndexBackup(); if (backup != null) { index.indexSearcherOpen(backup); writer = index.getIndexWriter(report, true); if (writer instanceof CmsSolrIndexWriter) { try { Messages.get().container(Messages.RPT_SEARCH_INDEXING_REBUILD_BEGIN_1, index.getName()), I_CmsReport.FORMAT_HEADLINE); Iterator<CmsSearchIndexSource> sources = index.getSources().iterator(); while (sources.hasNext()) { Messages.get().getBundle().key( Messages.LOG_IO_INDEX_WRITER_COMMIT_2, index.getName(), index.getPath()), e); Messages.get().getBundle().key(
LOG.debug(Messages.get().getBundle().key(Messages.LOG_SEARCH_PARAMS_2, params, getName())); if (getPriority() > 0) { Thread.currentThread().setPriority(getPriority()); searchCms.getRequestContext().setCurrentProject(searchCms.readProject(getProject())); filter = appendPathFilter(searchCms, filter, params.getRoots()); filter = appendCategoryFilter(searchCms, filter, params.getCategories()); filter = appendResourceTypeFilter(searchCms, filter, params.getResourceTypes()); filter = appendDateLastModifiedFilter( filter, params.getMinDateLastModified(), params.getMaxDateLastModified()); filter = appendDateCreatedFilter(filter, params.getMinDateCreated(), params.getMaxDateCreated()); indexSearcherUpdate(); IndexSearcher searcher = getSearcher(); QueryParser p = new QueryParser(CmsSearchField.FIELD_CONTENT, getAnalyzer()); fieldsQuery = p.parse(params.getParsedQuery()); } else if (params.getFieldQueries() != null) { QueryParser p = new QueryParser(fq.getFieldName(), getAnalyzer());
indexElement.addElement(N_NAME).addText(searchIndex.getName()); indexElement.addElement(N_REBUILD).addText(searchIndex.getRebuildMode()); indexElement.addElement(N_PROJECT).addText(searchIndex.getProject()); indexElement.addElement(N_LOCALE).addText(searchIndex.getLocale().toString()); String fieldConfigurationName = searchIndex.getFieldConfigurationName(); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(fieldConfigurationName)) { indexElement.addElement(N_CONFIGURATION).addText(fieldConfigurationName); Iterator sourcesIterator = searchIndex.getSourceNames().iterator(); while (sourcesIterator.hasNext()) { Map indexConfiguration = searchIndex.getConfiguration(); if (indexConfiguration != null) { Iterator it = indexConfiguration.entrySet().iterator();
LOG.debug(Messages.get().getBundle().key(Messages.LOG_SEARCH_PARAMS_2, params, getName())); if (getPriority() > 0) { Thread.currentThread().setPriority(getPriority()); searchCms.getRequestContext().setCurrentProject(searchCms.readProject(getProject())); extendPathFilter(pathFilter, searchRoot); extendPathFilter(pathFilter, searchCms.getRequestContext().getSiteRoot()); filter.add(new FilterClause(getMultiTermQueryFilter( CmsSearchField.FIELD_CATEGORY, params.getCategories()), BooleanClause.Occur.MUST)); filter.add(new FilterClause(getMultiTermQueryFilter( CmsSearchField.FIELD_TYPE, params.getResourceTypes()), BooleanClause.Occur.MUST)); QueryParser p = new QueryParser(fq.getFieldName(), getAnalyzer()); if (BooleanClause.Occur.SHOULD.equals(fq.getOccur())) { if (shouldOccur == null) { fieldsQuery = getSearcher().rewrite(booleanFieldsQuery); } else if ((params.getFields() != null) && (params.getFields().size() > 0)) { QueryParser p = new QueryParser(params.getFields().get(i), getAnalyzer()); booleanFieldsQuery.add(p.parse(params.getQuery()), BooleanClause.Occur.SHOULD);
if (!isEnabled()) { m_sources = new ArrayList<CmsSearchIndexSource>(); m_path = getPath(); setEnabled(false); throw new CmsSearchException( Messages.get().container(Messages.ERR_INDEX_SOURCE_ASSOCIATION_1, sourceName), Analyzer baseAnalyzer = OpenCms.getSearchManager().getAnalyzer(getLocale()); if (getFieldConfiguration() instanceof CmsLuceneFieldConfiguration) { CmsLuceneFieldConfiguration fc = (CmsLuceneFieldConfiguration)getFieldConfiguration(); setAnalyzer(fc.getAnalyzer(baseAnalyzer)); indexSearcherOpen(getPath());
if ((searchIndex.getSources() == null) || (searchIndex.getPath() == null)) { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { try { searchIndex.initialize(); } catch (CmsSearchException e) { String name = searchIndex.getName(); if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) { throw new CmsIllegalArgumentException(Messages.get().container( CmsLog.INIT.info(Messages.get().getBundle().key( Messages.INIT_ADD_SEARCH_INDEX_2, searchIndex.getName(), searchIndex.getProject()));
/** * Commits the edited search index to the search manager.<p> */ @Override public void actionCommit() { List<Throwable> errors = new ArrayList<Throwable>(); try { // if new create it first if (!m_searchManager.getSearchIndexesAll().contains(m_index)) { // check the index name for invalid characters CmsStringUtil.checkName( m_index.getName(), INDEX_NAME_CONSTRAINTS, Messages.ERR_SEARCHINDEX_BAD_INDEXNAME_4, Messages.get()); // empty or null name and uniqueness check in add method m_searchManager.addSearchIndex(m_index); } // check if field configuration has been updated, if thus set field configuration to the now used if (!m_index.getFieldConfigurationName().equals(m_index.getFieldConfiguration().getName())) { m_index.setFieldConfiguration( m_searchManager.getFieldConfiguration(m_index.getFieldConfigurationName())); } writeConfiguration(); } catch (Throwable t) { errors.add(t); } // set the list of errors to display when saving failed setCommitErrors(errors); }
if (isEnabled()) { cms.readProject(getProject()); setEnabled(true); } catch (CmsException e) { setEnabled(false); if (LOG.isErrorEnabled()) { LOG.error( Messages.get().getBundle().key( Messages.LOG_SEARCHINDEX_CREATE_BAD_PROJECT_2, getProject(), getName())); LOG.info(Messages.get().getBundle().key(Messages.LOG_SEARCHINDEX_DISABLED_1, getName())); return isEnabled();
Iterator<CmsSearchIndexSource> sources = index.getSources().iterator(); while (sources.hasNext()) { Messages.get().container(Messages.RPT_SEARCH_INDEXING_UPDATE_BEGIN_1, index.getName()), I_CmsReport.FORMAT_HEADLINE); try { writer = index.getIndexWriter(false); LOG.error(Messages.get().getBundle().key( Messages.LOG_IO_INDEX_WRITER_CLOSE_2, index.getPath(), index.getName()), e); index.indexSearcherOpen(index.getPath()); Messages.get().container(Messages.RPT_SEARCH_INDEXING_UPDATE_END_1, index.getName()), I_CmsReport.FORMAT_HEADLINE);
/** * Get the name of the index for the search.<p> * * @return the name of the index for the search */ public String getIndex() { return m_index.getName(); }
if (!isEnabled()) { setEnabled(false); throw new CmsSearchException(Messages.get().container( Messages.ERR_INDEX_SOURCE_ASSOCIATION_1, Analyzer baseAnalyzer = OpenCms.getSearchManager().getAnalyzer(getLocale()); setAnalyzer(m_fieldConfiguration.getAnalyzer(baseAnalyzer)); indexSearcherOpen(m_path);
/** * Updates the offline search indexes for the given list of resources.<p> * * @param report the report to write the index information to * @param resourcesToIndex the list of {@link CmsPublishedResource} objects to index */ protected void updateIndexOffline(I_CmsReport report, List<CmsPublishedResource> resourcesToIndex) { CmsObject cms = m_adminCms; try { // copy the administration context for the indexing cms = OpenCms.initCmsObject(m_adminCms); // set site root and project for this index cms.getRequestContext().setSiteRoot("/"); } catch (CmsException e1) { // NOOP, should never happen } Iterator<CmsSearchIndex> j = m_offlineIndexes.iterator(); while (j.hasNext()) { CmsSearchIndex index = j.next(); if (index.getSources() != null) { try { // switch to the index project cms.getRequestContext().setCurrentProject(cms.readProject(index.getProject())); updateIndexIncremental(cms, index, report, resourcesToIndex); } catch (CmsException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_UPDATE_INDEX_FAILED_1, index.getName()), e); } } } }
Iterator<CmsSearchIndexSource> sources = index.getSources().iterator(); while (sources.hasNext()) { Messages.get().container(Messages.RPT_SEARCH_INDEXING_UPDATE_BEGIN_1, index.getName()), I_CmsReport.FORMAT_HEADLINE); try { writer = index.getIndexWriter(report, false); Messages.get().getBundle().key( Messages.LOG_IO_INDEX_WRITER_COMMIT_2, index.getName(), index.getPath()), e); index.indexSearcherUpdate(); Messages.get().container(Messages.RPT_SEARCH_INDEXING_UPDATE_END_1, index.getName()), I_CmsReport.FORMAT_HEADLINE);
if (index.isExtractingContent()) { cacheName = cache.getCacheName(resource, isLocaleDependend() ? index.getLocale() : null); content = cache.getCacheObject(cacheName); Document oldDoc = index.getDocument(resource.getRootPath()); return index.getFieldConfiguration().createDocument(cms, resource, index, content);
/** * Returns select options for all configures Solr Offline indexes.<p> * * @return select options for all configures Solr Offline indexes */ private List<CmsSelectWidgetOption> getSolrIndexOptions() { List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>(); result.add( new CmsSelectWidgetOption(CmsSearchReplaceSettings.VFS, true, CmsSearchReplaceSettings.VFS.toUpperCase())); if (OpenCms.getSearchManager().getSolrServerConfiguration().isEnabled()) { for (CmsSearchIndex index : OpenCms.getSearchManager().getAllSolrIndexes()) { if (CmsSearchIndex.REBUILD_MODE_OFFLINE.equals(index.getRebuildMode())) { result.add(new CmsSelectWidgetOption(index.getName(), false, index.getName())); } } } return result; }