/** * Returns the configured Solr home directory <code>null</code> if not set.<p> * * @return the Solr home directory */ public String getDirectorySolr() { return m_solrConfig != null ? m_solrConfig.getHome() : null; }
Element solr = searchElement.addElement(N_SOLR); CmsSolrConfiguration conf = m_searchManager.getSolrServerConfiguration(); solr.addAttribute(A_ENABLED, new Boolean(conf.isEnabled()).toString()); if (conf.getServerUrl() != null) { solr.addAttribute(A_SERVER_URL, conf.getServerUrl().toString()); if (conf.getHomeFolderPath() != null) { solr.addElement(N_HOME).addText(conf.getHomeFolderPath()); if (conf.getSolrFileName() != null) { solr.addElement(N_CONFIG_FILE).addText(conf.getSolrFileName()); solr.addElement(N_COMMIT_MS).addText(String.valueOf(conf.getSolrCommitMs()));
if ((m_solrConfig == null) || !m_solrConfig.isEnabled()) { if (m_solrConfig.getServerUrl() != null) { index.setSolrServer(new HttpSolrClient(m_solrConfig.getServerUrl())); m_solrConfig.getHome() + FileSystems.getDefault().getSeparator() + index.getName()); if (!instanceDir.exists()) { instanceDir.mkdirs(); index.getName() + " (" + index.getCoreName() + ")", index.getPath(), m_solrConfig.getSolrConfigFile().getAbsolutePath()), e);
/** * Returns <code>true</code> if Solr search is enabled.<p> * * @return <code>true</code> if Solr search is enabled */ private boolean isSolrEnabled() { boolean solrEnabled = OpenCms.getSearchManager().getSolrServerConfiguration().isEnabled(); CmsSolrIndex solrIndex = OpenCms.getSearchManager().getIndexSolr(CmsSolrIndex.DEFAULT_INDEX_NAME_OFFLINE); return solrEnabled && (solrIndex != null); } }
/** * Returns the Solr index schema.<p> * * @return the Solr index schema */ public IndexSchema getSolrSchema() { if (m_schema == null) { try { InputSource solrSchema = new InputSource(new FileInputStream(getSolrSchemaFile())); m_schema = new IndexSchema(getSolrConfig(), SOLR_SCHEMA_NAME, solrSchema); } catch (FileNotFoundException e) { CmsConfigurationException ex = new CmsConfigurationException( Messages.get().container( Messages.LOG_SOLR_ERR_SCHEMA_XML_NOT_FOUND_1, getSolrSchemaFile().getPath()), e); LOG.error(ex.getLocalizedMessage(), ex); } } return m_schema; }
/** * Creates the Solr core container.<p> * * @return the created core container */ private CoreContainer createCoreContainer() { CoreContainer container = null; try { // get the core container // still no core container: create it container = CoreContainer.createAndLoad( Paths.get(m_solrConfig.getHome()), m_solrConfig.getSolrFile().toPath()); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( Messages.get().getBundle().key( Messages.INIT_SOLR_CORE_CONTAINER_CREATED_2, m_solrConfig.getHome(), m_solrConfig.getSolrFile().getName())); } } catch (Exception e) { LOG.error( Messages.get().getBundle().key( Messages.ERR_SOLR_CORE_CONTAINER_NOT_CREATED_1, m_solrConfig.getSolrFile().getAbsolutePath()), e); } return container; }
/** * Returns the Solr configuration (object representation of <code>'solrconfig.xml'</code>).<p> * * @return the Solr configuration * */ public SolrConfig getSolrConfig() { if (m_solrConfig == null) { try { InputSource solrConfig = new InputSource(new FileInputStream(getSolrConfigFile())); m_solrConfig = new SolrConfig(Paths.get(getHome(), DEFAULT_CONFIGSET_FOLDER), null, solrConfig); } catch (FileNotFoundException e) { CmsConfigurationException ex = new CmsConfigurationException( Messages.get().container(Messages.LOG_SOLR_ERR_CONFIG_XML_NOT_FOUND_1, getSolrConfigFile()), e); LOG.error(ex.getLocalizedMessage(), ex); } catch (Exception e) { CmsConfigurationException ex = new CmsConfigurationException( Messages.get().container(Messages.LOG_SOLR_ERR_CONFIG_XML_NOT_READABLE_1, getSolrConfigFile()), e); LOG.error(ex.getLocalizedMessage(), ex); } } return m_solrConfig; }
/** * @see org.opencms.search.I_CmsSearchDocument#addFileSizeField(int) */ public void addFileSizeField(int length) { if (OpenCms.getSearchManager().getSolrServerConfiguration().getSolrSchema().hasExplicitField( CmsSearchField.FIELD_SIZE)) { m_doc.addField(CmsSearchField.FIELD_SIZE, new Integer(length)); } }
/** * 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; }
fieldsToAdd.addAll(field.getCopyFields()); IndexSchema schema = OpenCms.getSearchManager().getSolrServerConfiguration().getSolrSchema(); for (String fieldName : fieldsToAdd) { try {
SearchType.contentValues, CmsVaadinUtils.getMessageText(Messages.GUI_SOURCESEARCH_SERACH_TYPE_XMLCONTENT_0)); if (OpenCms.getSearchManager().getSolrServerConfiguration().isEnabled()) {
/** * Returns the Solr xml file, default: <code>'solr.xml'</code>.<p> * * @return the Solr xml file */ public File getSolrFile() { if (m_solrFile == null) { String solrFileName = m_solrFileName != null ? m_solrFileName : SOLR_CONFIG_FILE; m_solrFile = new File(getHome() + File.separator + solrFileName); } return m_solrFile; }
rb.doHighlights = true; DocListAndSet res = new DocListAndSet(); SchemaField idField = OpenCms.getSearchManager().getSolrServerConfiguration().getSolrSchema().getUniqueKeyField();
/** * Returns the solr configuration file, default: <code>'conf/solrconfig.xml'</code>.<p> * * @return the solr configuration file */ public File getSolrConfigFile() { return new File(getHome() + DEFAULT_CONFIGSET_FOLDER + CONF_FOLDER + SolrConfig.DEFAULT_CONF_FILE); }
/** * Public constructor.<p> * * @param luceneField */ public CmsSolrField(CmsLuceneField luceneField) { super(); String name = luceneField.getName(); IndexSchema schema = OpenCms.getSearchManager().getSolrServerConfiguration().getSolrSchema(); if (schema.hasExplicitField(name)) { // take the lucene field name for Solr } else if ((luceneField.getType() != null) && schema.isDynamicField(luceneField.getName() + "_" + luceneField.getType())) { // try to use the specified type attribute as dynamic field suffix name = luceneField.getName() + "_" + luceneField.getType(); } else { // fallback create a general_text field name = luceneField.getName() + "_txt"; } setName(name); setBoost(luceneField.getBoost()); setDefaultValue(luceneField.getDefaultValue()); for (I_CmsSearchFieldMapping mapping : luceneField.getMappings()) { addMapping(mapping); } }
/** * Returns the Solr index schema file.<p> * * @return the Solr index schema file */ public File getSolrSchemaFile() { return new File(getHome() + DEFAULT_CONFIGSET_FOLDER + CONF_FOLDER + IndexSchema.DEFAULT_SCHEMA_FILE); }