mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-10 14:11:25 +00:00
[MNT-23154]
Allow custom d:content properties to be indexed Added flag in solrcore.properties (cherry picked from commit e9e2c1c64958b74e47021678a3fc35a3075a874b)
This commit is contained in:
@@ -361,6 +361,9 @@ public class SolrInformationServer implements InformationServer
|
||||
private static final long CONTENT_OUTDATED_MARKER = -10;
|
||||
private static final long CONTENT_UPDATED_MARKER = -20;
|
||||
|
||||
private static final String CONTENT_FIELD_NAME = "contentFieldName";
|
||||
|
||||
private static final String CONTENT_LOCALE = "contentLocale";
|
||||
private static final String CONTENT_LOCALE_FIELD = "content@s__locale@{http://www.alfresco.org/model/content/1.0}content";
|
||||
private static final Set<String> ID_AND_CONTENT_VERSION_ID_AND_CONTENT_LOCALE =
|
||||
new HashSet<>(asList(FIELD_SOLR4_ID, LATEST_APPLIED_CONTENT_VERSION_ID, CONTENT_LOCALE_FIELD));
|
||||
@@ -460,6 +463,8 @@ public class SolrInformationServer implements InformationServer
|
||||
|
||||
private final boolean dateFieldDestructuringHasBeenEnabledOnThisInstance;
|
||||
|
||||
private final boolean enabledIndexCustomContent;
|
||||
|
||||
static class DocListCollector implements Collector, LeafCollector
|
||||
{
|
||||
private final IntArrayList docs = new IntArrayList();
|
||||
@@ -642,6 +647,8 @@ public class SolrInformationServer implements InformationServer
|
||||
port = portNumber(props);
|
||||
baseUrl = baseUrl(props);
|
||||
|
||||
enabledIndexCustomContent = Boolean.parseBoolean(coreConfiguration.getProperty("solr.enableIndexingCustomContent", "false"));
|
||||
|
||||
dateFieldDestructuringHasBeenEnabledOnThisInstance = Boolean.parseBoolean(coreConfiguration.getProperty("alfresco.destructureDateFields", "true"));
|
||||
LOGGER.info(
|
||||
"Date fields destructuring has been {} on this instance.",
|
||||
@@ -999,9 +1006,27 @@ public class SolrInformationServer implements InformationServer
|
||||
String idString = id.stringValue();
|
||||
TenantDbId tenantAndDbId = AlfrescoSolrDataModel.decodeNodeDocumentId(idString);
|
||||
|
||||
ofNullable(document.getField(CONTENT_LOCALE_FIELD))
|
||||
.map(IndexableField::stringValue)
|
||||
.ifPresent(value -> tenantAndDbId.setProperty(CONTENT_LOCALE_FIELD, value));
|
||||
if (enabledIndexCustomContent)
|
||||
{
|
||||
|
||||
document.getFields().stream()
|
||||
.filter(field -> field.name().startsWith(AlfrescoSolrDataModel.CONTENT_S_LOCALE_PREFIX))
|
||||
.findFirst()
|
||||
.ifPresent(field -> {
|
||||
tenantAndDbId.setProperty(CONTENT_FIELD_NAME, field.name());
|
||||
tenantAndDbId.setProperty(CONTENT_LOCALE, field.stringValue());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ofNullable(document.getField(CONTENT_LOCALE_FIELD))
|
||||
.map(IndexableField::stringValue)
|
||||
.ifPresent(value -> {
|
||||
tenantAndDbId.setProperty(CONTENT_FIELD_NAME, CONTENT_LOCALE_FIELD);
|
||||
tenantAndDbId.setProperty(CONTENT_LOCALE, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
tenantAndDbId.setProperty(
|
||||
LATEST_APPLIED_CONTENT_VERSION_ID,
|
||||
@@ -1933,7 +1958,7 @@ public class SolrInformationServer implements InformationServer
|
||||
docRef.tenant,
|
||||
docRef.dbId));
|
||||
|
||||
if (docRef.optionalBag.containsKey(CONTENT_LOCALE_FIELD))
|
||||
if (docRef.optionalBag.containsKey(CONTENT_FIELD_NAME))
|
||||
{
|
||||
addContentToDoc(docRef, doc, docRef.dbId);
|
||||
}
|
||||
@@ -2713,8 +2738,9 @@ public class SolrInformationServer implements InformationServer
|
||||
|
||||
private void addContentToDoc(TenantDbId docRef, SolrInputDocument doc, long dbId) throws AuthenticationException, IOException
|
||||
{
|
||||
String locale = (String) docRef.optionalBag.get(CONTENT_LOCALE_FIELD);
|
||||
String qNamePart = CONTENT_LOCALE_FIELD.substring(AlfrescoSolrDataModel.CONTENT_S_LOCALE_PREFIX.length());
|
||||
String fieldName = (String) docRef.optionalBag.get(CONTENT_FIELD_NAME);
|
||||
String locale = (String) docRef.optionalBag.get(CONTENT_LOCALE);
|
||||
String qNamePart = fieldName.substring(AlfrescoSolrDataModel.CONTENT_S_LOCALE_PREFIX.length());
|
||||
QName propertyQName = QName.createQName(qNamePart);
|
||||
addContentPropertyToDocUsingAlfrescoRepository(doc, propertyQName, dbId, locale);
|
||||
}
|
||||
|
@@ -234,6 +234,11 @@ solr.request.content.compress=false
|
||||
#
|
||||
solr.initial.transaction.range=0-2000
|
||||
|
||||
|
||||
# set it to true to allow custom d:content fields to be indexed.
|
||||
# N.B. At most one content field can be indexed for each document
|
||||
solr.enableIndexingCustomContent=false
|
||||
|
||||
# Facet query limit when retrieving info for the stats (used in the acl transaction and index transaction reports
|
||||
# and fix)
|
||||
alfresco.stats.facetLimit=100
|
||||
|
Reference in New Issue
Block a user