CmsSolrField newSolrField = new CmsSolrField((CmsLuceneField)field); m_solrFields.put(newSolrField.getName(), newSolrField); CmsSolrField solrField = new CmsSolrField( CmsSearchField.FIELD_CONTENT, null, null, CmsSearchField.BOOST_DEFAULT); solrField.addMapping( new CmsSearchFieldMapping(CmsSearchFieldMappingType.CONTENT, CmsSearchField.FIELD_CONTENT)); m_solrFields.put(solrField.getName(), solrField); for (Locale locale : OpenCms.getLocaleManager().getAvailableLocales()) { solrField = new CmsSolrField( CmsSearchFieldConfiguration.getLocaleExtendedName(CmsSearchField.FIELD_CONTENT, locale), Collections.singletonList(locale.toString() + CmsSearchField.FIELD_EXCERPT), null, CmsSearchField.BOOST_DEFAULT); solrField.addMapping( new CmsSearchFieldMapping(CmsSearchFieldMappingType.CONTENT, CmsSearchField.FIELD_CONTENT)); m_solrFields.put(solrField.getName(), solrField); CmsSolrField sfield = new CmsSolrField(CmsSearchField.FIELD_MIMETYPE, null, null, null, 0); m_solrFields.put(sfield.getName(), sfield); sfield = new CmsSolrField(CmsSearchField.FIELD_FILENAME, null, null, null, 0); m_solrFields.put(sfield.getName(), sfield);
/** * @see org.opencms.search.fields.CmsSearchField#toString() */ @Override public String toString() { return getName() + "[" + " boost:" + getBoost() + " defaultValue:" + getDefaultValue() + " targetField:" + getTargetField() + " locale:" + getLocale() + " copyFields:" + getCopyFields() + " ]"; } }
List<String> fieldsToAdd = new ArrayList<String>(Collections.singletonList(field.getName())); if ((field.getCopyFields() != null) && !field.getCopyFields().isEmpty()) { fieldsToAdd.addAll(field.getCopyFields()); if ((f != null) && (!field.getName().startsWith(CmsSearchField.FIELD_CONTENT))) { multi = f.multiValued(); LOG.warn(Messages.get().getBundle().key(Messages.LOG_SOLR_FIELD_NOT_FOUND_1, field.toString())); m_doc.addField(fieldName, val); } else { m_doc.addField(fieldName, val, field.getBoost());
/** * 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); } }
float boost = Float.valueOf( solrElement.attributeValue(APPINFO_ATTR_BOOST, defaultBoost)).floatValue(); CmsSolrField field = new CmsSolrField(targetField, copyFields, locale, defaultValue, boost); while (ite.hasNext()) { Element mappingElement = ite.next(); field.addMapping(createSearchFieldMapping(contentDefinition, mappingElement, locale)); if ((field.getMappings() == null) || field.getMappings().isEmpty()) { String param = locale.toString() + "|" + elementName; CmsSearchFieldMapping map = new CmsSearchFieldMapping(CmsSearchFieldMappingType.ITEM, param); field.addMapping(map);
try { StringBuffer text = new StringBuffer(); for (I_CmsSearchFieldMapping mapping : field.getMappings()) { if ((field.getLocale() != null) && mapping.getType().equals(CmsSearchFieldMappingType.CONTENT)) { mapResult = extractionResult.getContent(field.getLocale()); if (mapResult == null) { || CmsResourceTypeXmlPage.isXmlPage(resource))) { if ((m_contentLocales != null) && m_contentLocales.contains(field.getLocale())) { if ((text.length() <= 0) && (field.getDefaultValue() != null)) { text.append(field.getDefaultValue());
for (String fieldName : fieldMappings.keySet()) { String value = fieldMappings.get(fieldName); CmsSolrField f = new CmsSolrField(fieldName, null, null, null, 0); document.addSearchField(f, value); systemFields.add(fieldName);
/** * Adds the additional fields to the configuration, if they are not null.<p> * * @param additionalFields the additional fields to add */ public void addAdditionalFields(List<CmsSolrField> additionalFields) { if (additionalFields != null) { for (CmsSolrField solrField : additionalFields) { m_solrFields.put(solrField.getName(), solrField); } } }
/** * Adds a Solr field for an element.<p> * * @param contentDefinition the XML content definition this XML content handler belongs to * @param field the Solr field * @param type the type, specifying if the field should be attached to the document of the XML content or to all container pages the content is placed on */ protected void addSearchField( CmsXmlContentDefinition contentDefinition, CmsSearchField field, I_CmsXmlContentHandler.MappingType type) { Locale locale = null; if (field instanceof CmsSolrField) { locale = ((CmsSolrField)field).getLocale(); } String key = CmsXmlUtils.concatXpath(locale != null ? locale.toString() : null, field.getName()); switch (type) { case PAGE: m_searchFieldsPage.put(key, field); break; case ELEMENT: default: m_searchFields.put(key, field); break; } }
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(prop.getValue())) { document.addSearchField( new CmsSolrField( prop.getName() + CmsSearchField.FIELD_DYNAMIC_PROPERTIES, null, new CmsSolrField( prop.getName() + CmsSearchField.FIELD_DYNAMIC_PROPERTIES + "_s", null, if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(prop.getValue())) { document.addSearchField( new CmsSolrField( prop.getName() + CmsSearchField.FIELD_DYNAMIC_PROPERTIES_DIRECT, null, new CmsSolrField( prop.getName() + CmsSearchField.FIELD_DYNAMIC_PROPERTIES_DIRECT + "_s", null,
locale) + "_s"; final CmsSolrField f = new CmsSolrField(effFieldName, null, null, null, 0); document.addSearchField(f, value);