mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-17 14:21:20 +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_OUTDATED_MARKER = -10;
|
||||||
private static final long CONTENT_UPDATED_MARKER = -20;
|
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 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 =
|
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));
|
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 dateFieldDestructuringHasBeenEnabledOnThisInstance;
|
||||||
|
|
||||||
|
private final boolean enabledIndexCustomContent;
|
||||||
|
|
||||||
static class DocListCollector implements Collector, LeafCollector
|
static class DocListCollector implements Collector, LeafCollector
|
||||||
{
|
{
|
||||||
private final IntArrayList docs = new IntArrayList();
|
private final IntArrayList docs = new IntArrayList();
|
||||||
@@ -642,6 +647,8 @@ public class SolrInformationServer implements InformationServer
|
|||||||
port = portNumber(props);
|
port = portNumber(props);
|
||||||
baseUrl = baseUrl(props);
|
baseUrl = baseUrl(props);
|
||||||
|
|
||||||
|
enabledIndexCustomContent = Boolean.parseBoolean(coreConfiguration.getProperty("solr.enableIndexingCustomContent", "false"));
|
||||||
|
|
||||||
dateFieldDestructuringHasBeenEnabledOnThisInstance = Boolean.parseBoolean(coreConfiguration.getProperty("alfresco.destructureDateFields", "true"));
|
dateFieldDestructuringHasBeenEnabledOnThisInstance = Boolean.parseBoolean(coreConfiguration.getProperty("alfresco.destructureDateFields", "true"));
|
||||||
LOGGER.info(
|
LOGGER.info(
|
||||||
"Date fields destructuring has been {} on this instance.",
|
"Date fields destructuring has been {} on this instance.",
|
||||||
@@ -999,9 +1006,27 @@ public class SolrInformationServer implements InformationServer
|
|||||||
String idString = id.stringValue();
|
String idString = id.stringValue();
|
||||||
TenantDbId tenantAndDbId = AlfrescoSolrDataModel.decodeNodeDocumentId(idString);
|
TenantDbId tenantAndDbId = AlfrescoSolrDataModel.decodeNodeDocumentId(idString);
|
||||||
|
|
||||||
ofNullable(document.getField(CONTENT_LOCALE_FIELD))
|
if (enabledIndexCustomContent)
|
||||||
.map(IndexableField::stringValue)
|
{
|
||||||
.ifPresent(value -> tenantAndDbId.setProperty(CONTENT_LOCALE_FIELD, value));
|
|
||||||
|
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(
|
tenantAndDbId.setProperty(
|
||||||
LATEST_APPLIED_CONTENT_VERSION_ID,
|
LATEST_APPLIED_CONTENT_VERSION_ID,
|
||||||
@@ -1933,7 +1958,7 @@ public class SolrInformationServer implements InformationServer
|
|||||||
docRef.tenant,
|
docRef.tenant,
|
||||||
docRef.dbId));
|
docRef.dbId));
|
||||||
|
|
||||||
if (docRef.optionalBag.containsKey(CONTENT_LOCALE_FIELD))
|
if (docRef.optionalBag.containsKey(CONTENT_FIELD_NAME))
|
||||||
{
|
{
|
||||||
addContentToDoc(docRef, doc, docRef.dbId);
|
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
|
private void addContentToDoc(TenantDbId docRef, SolrInputDocument doc, long dbId) throws AuthenticationException, IOException
|
||||||
{
|
{
|
||||||
String locale = (String) docRef.optionalBag.get(CONTENT_LOCALE_FIELD);
|
String fieldName = (String) docRef.optionalBag.get(CONTENT_FIELD_NAME);
|
||||||
String qNamePart = CONTENT_LOCALE_FIELD.substring(AlfrescoSolrDataModel.CONTENT_S_LOCALE_PREFIX.length());
|
String locale = (String) docRef.optionalBag.get(CONTENT_LOCALE);
|
||||||
|
String qNamePart = fieldName.substring(AlfrescoSolrDataModel.CONTENT_S_LOCALE_PREFIX.length());
|
||||||
QName propertyQName = QName.createQName(qNamePart);
|
QName propertyQName = QName.createQName(qNamePart);
|
||||||
addContentPropertyToDocUsingAlfrescoRepository(doc, propertyQName, dbId, locale);
|
addContentPropertyToDocUsingAlfrescoRepository(doc, propertyQName, dbId, locale);
|
||||||
}
|
}
|
||||||
|
@@ -234,6 +234,11 @@ solr.request.content.compress=false
|
|||||||
#
|
#
|
||||||
solr.initial.transaction.range=0-2000
|
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
|
# Facet query limit when retrieving info for the stats (used in the acl transaction and index transaction reports
|
||||||
# and fix)
|
# and fix)
|
||||||
alfresco.stats.facetLimit=100
|
alfresco.stats.facetLimit=100
|
||||||
|
Reference in New Issue
Block a user