List of usage examples for com.liferay.portal.kernel.search Field UNSCORED_FIELD_NAMES
String[] UNSCORED_FIELD_NAMES
To view the source code for com.liferay.portal.kernel.search Field UNSCORED_FIELD_NAMES.
Click Source Link
From source file:org.rsc.liferay.solr.SolrIndexWriter.java
License:Open Source License
protected SolrInputDocument getSolrInputDocument(Document document) { SolrInputDocument solrInputDocument = new SolrInputDocument(); Collection<Field> fields = document.getFields().values(); for (Field field : fields) { String name = field.getName(); float boost = field.getBoost(); if (ArrayUtil.contains(Field.UNSCORED_FIELD_NAMES, name)) { boost = _UNSCORED_FIELDS_BOOST; }/* w w w. jav a2 s.co m*/ if (!field.isLocalized()) { for (String value : field.getValues()) { if (Validator.isNull(value)) { continue; } solrInputDocument.addField(name, value.trim(), boost); } } else { Map<Locale, String> localizedValues = field.getLocalizedValues(); for (Map.Entry<Locale, String> entry : localizedValues.entrySet()) { String value = entry.getValue(); if (Validator.isNull(value)) { continue; } Locale locale = entry.getKey(); String languageId = LocaleUtil.toLanguageId(locale); String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getDefault()); if (languageId.equals(defaultLanguageId)) { solrInputDocument.addField(name, value.trim(), boost); } String localizedName = DocumentImpl.getLocalizedName(locale, name); solrInputDocument.addField(localizedName, value.trim(), boost); } } } return solrInputDocument; }