Class SolrIndexer
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.content.indexing.solr.SolrIndexer
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Contextualizable
,Serviceable
public class SolrIndexer
extends AbstractLogEnabled
implements Component, Serviceable, Initializable, Contextualizable
Solr indexer.
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The Ametys internal URL used by Solr to query Ametysprotected Context
The avalon contextprotected ReadAccessHelper
The helper for read accessprotected JackrabbitRepository
The JCR repositoryprotected AmetysObjectResolver
The ametys object resolver.protected SchemaDefinitionProviderExtensionPoint
The schema definition provider extension point.protected SchemaHelper
The schema helper.protected SolrClientProvider
The Solr client providerprotected SolrContentIndexer
Solr Ametys contents indexerprotected String
The solr core prefix.protected SolrResourceIndexer
Solr resource indexer.protected SolrWorkflowIndexer
Solr workflow indexer.protected WorkspaceSelector
The workspace selector.static final String
The component role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.solr.client.solrj.SolrClient
_getAutoCommitSolrClient
(String workspaceName) Gets the 'autocommit' Solr clientprotected org.apache.solr.client.solrj.SolrClient
_getNoAutoCommitSolrClient
(String workspaceName) Gets the 'no autocommit' Solr clientprotected void
_indexResourceDocument
(Resource resource, org.apache.solr.common.SolrInputDocument document, org.apache.solr.client.solrj.SolrClient solrClient) Index a populated solr input document of type Resource.protected void
addCustomUpdates
(List<org.apache.solr.client.solrj.request.schema.SchemaRequest.Update> updates, SchemaFields schemaFields) Compute the list of customSchemaRequest.Update
directives.protected void
addStaticSchemaUpdates
(List<org.apache.solr.client.solrj.request.schema.SchemaRequest.Update> updates, org.apache.solr.client.solrj.response.schema.SchemaRepresentation staticSchema, SchemaFields schemaFields) Compute the list ofSchemaRequest.Update
directives from the static schema.protected void
clearSchema
(org.apache.solr.client.solrj.SolrClient solrClient, String collection) Delete all the fields of the existing schema in the given collection.void
commit()
Process a Solr commit operation in all workspaces.void
Process a Solr commit operation in given workspace.void
contextualize
(Context context) void
createCore
(String name) Create a Solr core.static SimpleDateFormat
Deprecated.void
deleteCore
(String name) Delete a Solr core.protected void
deleteRepeaterDocs
(String contentId, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) Delete repeater documents of a specified content.protected void
doIndexContent
(Content content, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) Add or update a content into Solr indexprotected org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult
doIndexContents
(Iterable<Content> contents, String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) Send some contents for indexation in the solr server.protected void
doIndexContentWorkflow
(Content content, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) Index the whole workflow of a content.protected void
doIndexExplorerItem
(AmetysObject node, String documentType, TraversableAmetysObject resourceRoot, org.apache.solr.client.solrj.SolrClient solrClient) Add or update a resource into Solr indexprotected void
doIndexResource
(Resource resource, String documentType, TraversableAmetysObject resourceRoot, org.apache.solr.client.solrj.SolrClient solrClient) Add or update a resource into Solr indexprotected org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult
doIndexResources
(Iterable<? extends AmetysObject> resources, String documentType, TraversableAmetysObject resourceRoot, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) Send some resources for indexation in the solr server.protected void
doUnindexContentAttachments
(String contentId, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) Delete content attachments documents of a given content from the Solr server.protected void
doUnindexDocument
(String id, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) Delete a document from the Solr server.Get the names of the Solr cores.Get the names of the Solr cores.void
indexAclInitValues
(AmetysObject ametysObject, org.apache.solr.common.SolrInputDocument document) Indexes read-ACl initial values for objectindexAllContents
(String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) Index all the contents in a given workspace.indexAllContents
(String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) Index all the contents in a given workspace.indexAllResources
(String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) Index all the resources in a given workspace.void
indexContent
(String contentId, boolean indexAttachments) Add or update a content into Solr index on all workspaces and commitvoid
indexContent
(String contentId, String workspaceName, boolean indexAttachments) Add or update a content into Solr indexvoid
indexContent
(String contentId, String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) Add or update a content into Solr indexvoid
indexContentAttachment
(Resource resource, Content content) Index a content attachmentvoid
indexContentAttachment
(Resource resource, Content content, org.apache.solr.client.solrj.SolrClient solrClient) Index a content attachmentvoid
indexContentAttachments
(ResourceCollection collection, Content content) Index content attachments as new entries in the idnexvoid
indexContentAttachments
(ResourceCollection collection, Content content, org.apache.solr.client.solrj.SolrClient solrClient) Index content attachments as new entries in the idnexorg.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult
indexContents
(Iterable<Content> contents) Send a collection of contents for indexation in the solr server on all workspaces and commitorg.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult
indexContents
(Iterable<Content> contents, String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) Send a collection of contents for indexation in the solr server.org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult
indexContents
(Iterable<Content> contents, String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) Send a collection of contents for indexation in the solr server.org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult
indexContents
(Iterable<Content> contents, ContainerProgressionTracker progressionTracker) Send a collection of contents for indexation in the solr server on all workspaces and commitvoid
indexResource
(Resource resource, String documentType, String workspaceName) Add or update a resource into Solr indexorg.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult
indexResources
(Iterable<? extends AmetysObject> resources, String documentType, TraversableAmetysObject resourceRoot, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) Send a collection of contents for indexation in the solr server.org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult
indexResources
(Iterable<? extends AmetysObject> resources, String documentType, TraversableAmetysObject resourceRoot, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) Send a collection of contents for indexation in the solr server.org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult
indexResources
(Iterable<AmetysObject> resources, String documentType, String workspaceName) Send a collection of contents for indexation in the solr server.void
indexSubcontents
(String collectionId, boolean indexAttachments) Add or update the child contents of aAmetysObjectCollection
into Solr index, for all workspaces and commitvoid
indexSubcontents
(String collectionId, String workspaceName, boolean indexAttachments) Index the child contents of aAmetysObjectCollection
void
void
Launch a solr index optimization.void
Reloads the ACL Solr cache for all usersvoid
reloadAclCache
(String workspaceName) Reloads the ACL Solr cache for all usersvoid
reloadAclCache
(String workspaceName, boolean checkIfNecessary) Reloads the ACL Solr cache for all usersprotected void
Reload the solr cores.void
Send the schema.void
service
(ServiceManager serviceManager) static String
truncateUtf8StringValue
(String value, Logger logger, String documentId, String fieldName) Truncates (if needed) the given string in order to be indexed without immense term error by Solr.protected void
unindexAllContents
(String workspaceName, boolean unindexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) Unindex all content documents.void
unindexAllDocuments
(String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) Delete all documents from the solr index.void
unindexContent
(String contentId, boolean unindexAttachments) Remove a content from Solr index for all workspaces and commitvoid
unindexContent
(String contentId, String workspaceName, boolean unindexAttachments) Remove a content from Solr indexvoid
unindexContent
(String contentId, String workspaceName, boolean unindexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) Remove a content from Solr indexvoid
unindexContents
(Collection<String> contentIds) Remove a content from Solr index for all workspaces and commitvoid
unindexContents
(Collection<String> contentIds, String workspaceName) Remove a content from Solr indexvoid
unindexResource
(String resourceId) Remove a resource from Solr index for all workspaces and commitvoid
unindexResource
(String resourceId, String workspaceName) Remove a resource from the Solr index.void
unindexResourcesByPath
(String rootId, String path) Delete all resource documents at a given path for all workspaces and commitvoid
unindexResourcesByPath
(String rootId, String path, String workspaceName) Delete all resource documents at a given path.void
updateAclCache
(Iterable<? extends AmetysObject> objects) Updates the ACL Solr cache for someAmetysObject
s for all workspaces.void
updateAclCache
(Iterable<? extends AmetysObject> objects, String workspaceName) Updates the ACL Solr cache for someAmetysObject
s.void
Updates the ametys.url property of the Solr cores.void
updateProperty
(Content content, String propertyId, String workspaceName) Update the value of a specific property in a content document.void
updateProperty
(Content content, String propertyId, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) Update the value of a specific property in a content document.void
updateSystemProperty
(Content content, String propertyId, String workspaceName) Update the value of a specific system property in a content document.void
updateSystemProperty
(Content content, String propertyId, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) Update the value of a specific system property in a content document.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The component role. -
_resolver
The ametys object resolver. -
_schemaDefProviderEP
The schema definition provider extension point. -
_schemaHelper
The schema helper. -
_solrContentIndexer
Solr Ametys contents indexer -
_solrWorkflowIndexer
Solr workflow indexer. -
_solrResourceIndexer
Solr resource indexer. -
_solrClientProvider
The Solr client provider -
_solrCorePrefix
The solr core prefix. -
_ametysInternalUrl
The Ametys internal URL used by Solr to query Ametys -
_workspaceSelector
The workspace selector. -
_repository
The JCR repository -
_readAccessHelper
The helper for read access -
_context
The avalon context
-
-
Constructor Details
-
SolrIndexer
public SolrIndexer()
-
-
Method Details
-
dateFormat
Deprecated.useDateUtils.zonedDateTimeToString(java.time.ZonedDateTime, java.time.ZoneId)
using UTC zone id insteadReturns the formatter for indexing dates. This is used for adding a dates as formatted strings (and not with date object directly) to prevent indexing of the wrong value because of time zone- Returns:
- The date format for indexing dates
-
truncateUtf8StringValue
public static String truncateUtf8StringValue(String value, Logger logger, String documentId, String fieldName) Truncates (if needed) the given string in order to be indexed without immense term error by Solr. Only the 32766 first bytes of the String will be kept.- Parameters:
value
- The string value to indexlogger
- The logger for logging in WARN level in case the given string is too long and will be truncated. Can be null if you do not want to log.documentId
- The id of the document being indexed. Can be null if you do not want to log.fieldName
- The name of the field being indexed. Can be null if you do not want to log.- Returns:
- The given string value, or its truncation if it is too long (greater than 32766 bytes)
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
_getAutoCommitSolrClient
Gets the 'autocommit' Solr client- Parameters:
workspaceName
- The name of the workspace- Returns:
- the Solr client
-
_getNoAutoCommitSolrClient
Gets the 'no autocommit' Solr client- Parameters:
workspaceName
- The name of the workspace- Returns:
- the Solr client
-
getCoreNames
public Set<String> getCoreNames() throws IOException, org.apache.solr.client.solrj.SolrServerExceptionGet the names of the Solr cores.- Returns:
- The names of the Solr cores.
- Throws:
IOException
- If an I/O error occurs.org.apache.solr.client.solrj.SolrServerException
- If a Solr error occurs.
-
getRealCoreNames
protected Set<String> getRealCoreNames() throws IOException, org.apache.solr.client.solrj.SolrServerExceptionGet the names of the Solr cores.- Returns:
- The names of the Solr cores.
- Throws:
IOException
- If an I/O error occurs.org.apache.solr.client.solrj.SolrServerException
- If a Solr error occurs.
-
createCore
public void createCore(String name) throws IOException, org.apache.solr.client.solrj.SolrServerException Create a Solr core.- Parameters:
name
- The name of the core to create.- Throws:
IOException
- If an I/O error occurs.org.apache.solr.client.solrj.SolrServerException
- If a Solr error occurs.
-
updateAmetysUrlCoreProperty
Updates the ametys.url property of the Solr cores. -
deleteCore
public void deleteCore(String name) throws IOException, org.apache.solr.client.solrj.SolrServerException Delete a Solr core.- Parameters:
name
- The name of the core to delete.- Throws:
IOException
- If an I/O error occurs.org.apache.solr.client.solrj.SolrServerException
- If a Solr error occurs.
-
sendSchema
Send the schema.- Throws:
IOException
- If a communication error occurs.org.apache.solr.client.solrj.SolrServerException
- If a solr error occurs.
-
addStaticSchemaUpdates
protected void addStaticSchemaUpdates(List<org.apache.solr.client.solrj.request.schema.SchemaRequest.Update> updates, org.apache.solr.client.solrj.response.schema.SchemaRepresentation staticSchema, SchemaFields schemaFields) Compute the list ofSchemaRequest.Update
directives from the static schema.- Parameters:
updates
- The list ofSchemaRequest.Update
directives to fill.staticSchema
- The static schema representation.schemaFields
- The current schema fields, used to track the existing fields (to be filled).
-
addCustomUpdates
protected void addCustomUpdates(List<org.apache.solr.client.solrj.request.schema.SchemaRequest.Update> updates, SchemaFields schemaFields) Compute the list of customSchemaRequest.Update
directives.- Parameters:
updates
- The list ofSchemaRequest.Update
directives to fill.schemaFields
- The current schema fields, used to track the existing fields (to be filled).
-
clearSchema
protected void clearSchema(org.apache.solr.client.solrj.SolrClient solrClient, String collection) throws IOException, org.apache.solr.client.solrj.SolrServerException Delete all the fields of the existing schema in the given collection.- Parameters:
solrClient
- The Solr clientcollection
- The collection.- Throws:
IOException
- If a communication error occurs.org.apache.solr.client.solrj.SolrServerException
- If a solr error occurs.
-
reloadCores
Reload the solr cores.- Throws:
IOException
- If a communication error occurs.org.apache.solr.client.solrj.SolrServerException
- If a solr error occurs.
-
reloadAclCache
public void reloadAclCache() throws IOException, org.apache.solr.client.solrj.SolrServerException, javax.jcr.RepositoryExceptionReloads the ACL Solr cache for all users- Throws:
IOException
- If an I/O error occurs.org.apache.solr.client.solrj.SolrServerException
- If a Solr error occurs.javax.jcr.RepositoryException
- If a repository exception occurs when retrieving workspaces.
-
reloadAclCache
public void reloadAclCache(String workspaceName) throws IOException, org.apache.solr.client.solrj.SolrServerException Reloads the ACL Solr cache for all users- Parameters:
workspaceName
- The workspace name- Throws:
IOException
- If an I/O error occurs.org.apache.solr.client.solrj.SolrServerException
- If a Solr error occurs.
-
reloadAclCache
public void reloadAclCache(String workspaceName, boolean checkIfNecessary) throws IOException, org.apache.solr.client.solrj.SolrServerException Reloads the ACL Solr cache for all users- Parameters:
workspaceName
- The workspace namecheckIfNecessary
- true to check if the reload is necessary for each segment (i.e. reload only the segments not already in cache)- Throws:
IOException
- If an I/O error occurs.org.apache.solr.client.solrj.SolrServerException
- If a Solr error occurs.
-
updateAclCache
public void updateAclCache(Iterable<? extends AmetysObject> objects) throws IOException, org.apache.solr.client.solrj.SolrServerException, javax.jcr.RepositoryException Updates the ACL Solr cache for someAmetysObject
s for all workspaces.- Parameters:
objects
- theAmetysObject
s to update.- Throws:
IOException
- If an I/O error occurs.org.apache.solr.client.solrj.SolrServerException
- If a Solr error occurs.javax.jcr.RepositoryException
- If a repository exception occurs when retrieving workspaces.
-
updateAclCache
public void updateAclCache(Iterable<? extends AmetysObject> objects, String workspaceName) throws IOException, org.apache.solr.client.solrj.SolrServerException, javax.jcr.RepositoryException Updates the ACL Solr cache for someAmetysObject
s.- Parameters:
objects
- theAmetysObject
s to update.workspaceName
- The workspace name- Throws:
IOException
- If an I/O error occurs.org.apache.solr.client.solrj.SolrServerException
- If a Solr error occurs.javax.jcr.RepositoryException
- If a repository exception occurs when retrieving workspaces.
-
indexAllContents
public Map<String,Object> indexAllContents(String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Index all the contents in a given workspace.- Parameters:
workspaceName
- the workspace where to indexindexAttachments
- to index content attachmentssolrClient
- The solr client to use- Returns:
- The indexation result as a Map.
- Throws:
Exception
- if an error occurs while indexing.
-
indexAllContents
public Map<String,Object> indexAllContents(String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) throws Exception Index all the contents in a given workspace.- Parameters:
workspaceName
- the workspace where to indexindexAttachments
- to index content attachmentssolrClient
- The solr client to useprogressionTracker
- The progression of the indexation- Returns:
- The indexation result as a Map.
- Throws:
Exception
- if an error occurs while indexing.
-
unindexAllContents
protected void unindexAllContents(String workspaceName, boolean unindexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Unindex all content documents.- Parameters:
workspaceName
- The workspace nameunindexAttachments
- also unindex content attachmentssolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while unindexing.
-
indexSubcontents
Add or update the child contents of aAmetysObjectCollection
into Solr index, for all workspaces and commit- Parameters:
collectionId
- The id of collectionindexAttachments
- to index content attachments- Throws:
Exception
- if an error occurs while indexing.
-
indexSubcontents
public void indexSubcontents(String collectionId, String workspaceName, boolean indexAttachments) throws Exception Index the child contents of aAmetysObjectCollection
- Parameters:
collectionId
- The id of collectionworkspaceName
- the workspace where to indexindexAttachments
- to index content attachments- Throws:
Exception
- if an error occurs while unindexing.
-
indexContent
Add or update a content into Solr index on all workspaces and commit- Parameters:
contentId
- The id of the content to indexindexAttachments
- to index content attachments- Throws:
Exception
- if an error occurs while indexing.
-
indexContent
public void indexContent(String contentId, String workspaceName, boolean indexAttachments) throws Exception Add or update a content into Solr index- Parameters:
contentId
- The id of the content to indexworkspaceName
- the workspace where to indexindexAttachments
- to index content attachments- Throws:
Exception
- if an error occurs while indexing.
-
indexContent
public void indexContent(String contentId, String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Add or update a content into Solr index- Parameters:
contentId
- The id of the content to indexworkspaceName
- the workspace where to indexindexAttachments
- to index content attachmentssolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
indexContents
public org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult indexContents(Iterable<Content> contents) throws Exception Send a collection of contents for indexation in the solr server on all workspaces and commit- Parameters:
contents
- the collection of contents to index.- Returns:
- the indexation result.
- Throws:
Exception
- if an error occurs while indexing.
-
indexContents
public org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult indexContents(Iterable<Content> contents, ContainerProgressionTracker progressionTracker) throws Exception Send a collection of contents for indexation in the solr server on all workspaces and commit- Parameters:
contents
- the collection of contents to index.progressionTracker
- The progression of the indexation- Returns:
- the indexation result.
- Throws:
Exception
- if an error occurs while indexing.
-
indexContents
public org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult indexContents(Iterable<Content> contents, String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Send a collection of contents for indexation in the solr server.- Parameters:
contents
- the collection of contents to index.workspaceName
- the workspace where to indexindexAttachments
- to index content attachmentssolrClient
- The solr client to use- Returns:
- the indexation result.
- Throws:
Exception
- if an error occurs while indexing.
-
indexContents
public org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult indexContents(Iterable<Content> contents, String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) throws Exception Send a collection of contents for indexation in the solr server.- Parameters:
contents
- the collection of contents to index.workspaceName
- the workspace where to indexindexAttachments
- to index content attachmentssolrClient
- The solr client to useprogressionTracker
- The progression of the indexation- Returns:
- the indexation result.
- Throws:
Exception
- if an error occurs while indexing.
-
doIndexContents
protected org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult doIndexContents(Iterable<Content> contents, String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) throws Exception Send some contents for indexation in the solr server.- Parameters:
contents
- the contents to index.workspaceName
- The workspace nameindexAttachments
- to index content attachmentssolrClient
- The solr client to useprogressionTracker
- The progression of the indexation- Returns:
- the indexation result.
- Throws:
Exception
- if an error occurs committing the results.
-
updateSystemProperty
public void updateSystemProperty(Content content, String propertyId, String workspaceName) throws Exception Update the value of a specific system property in a content document.- Parameters:
content
- The content to update.propertyId
- The system property ID.workspaceName
- The workspace name- Throws:
Exception
- if an error occurs while indexing.
-
updateSystemProperty
public void updateSystemProperty(Content content, String propertyId, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Update the value of a specific system property in a content document.- Parameters:
content
- The content to update.propertyId
- The system property ID.workspaceName
- The workspace namesolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
updateProperty
public void updateProperty(Content content, String propertyId, String workspaceName) throws Exception Update the value of a specific property in a content document.- Parameters:
content
- The content to update.propertyId
- The system property ID.workspaceName
- The workspace name- Throws:
Exception
- if an error occurs while indexing.
-
updateProperty
public void updateProperty(Content content, String propertyId, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Update the value of a specific property in a content document.- Parameters:
content
- The content to update.propertyId
- The system property ID.workspaceName
- The workspace namesolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
unindexContent
Remove a content from Solr index for all workspaces and commit- Parameters:
contentId
- The id of content to unindexunindexAttachments
- also unindex content attachments- Throws:
Exception
- if an error occurs while indexing.
-
unindexContent
public void unindexContent(String contentId, String workspaceName, boolean unindexAttachments) throws Exception Remove a content from Solr index- Parameters:
contentId
- The id of content to unindexworkspaceName
- The workspace where to work inunindexAttachments
- also unindex content attachments- Throws:
Exception
- if an error occurs while indexing.
-
unindexContent
public void unindexContent(String contentId, String workspaceName, boolean unindexAttachments, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Remove a content from Solr index- Parameters:
contentId
- The id of content to unindexworkspaceName
- The workspace where to work inunindexAttachments
- also unindex content attachmentssolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
unindexContents
Remove a content from Solr index for all workspaces and commit- Parameters:
contentIds
- The id of content to unindex- Throws:
Exception
- if an error occurs while indexing.
-
unindexContents
Remove a content from Solr index- Parameters:
contentIds
- The id of content to unindexworkspaceName
- The workspace where to work in- Throws:
Exception
- if an error occurs while indexing.
-
doIndexContent
protected void doIndexContent(Content content, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Add or update a content into Solr index- Parameters:
content
- The content to indexworkspaceName
- The workspace where to indexsolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
indexAclInitValues
public void indexAclInitValues(AmetysObject ametysObject, org.apache.solr.common.SolrInputDocument document) Indexes read-ACl initial values for object- Parameters:
ametysObject
- The objectdocument
- The Solr document
-
doIndexContentWorkflow
protected void doIndexContentWorkflow(Content content, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Index the whole workflow of a content.- Parameters:
content
- The content.workspaceName
- The workspace namesolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
indexContentAttachments
public void indexContentAttachments(ResourceCollection collection, Content content) throws Exception Index content attachments as new entries in the idnex- Parameters:
collection
- the collection of attachmentscontent
- the content whose attachments will be indexed- Throws:
Exception
- if something goes wrong when indexing the attachments of the content
-
indexContentAttachments
public void indexContentAttachments(ResourceCollection collection, Content content, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Index content attachments as new entries in the idnex- Parameters:
collection
- the collection of attachmentscontent
- the content whose attachments will be indexedsolrClient
- The solr client to use- Throws:
Exception
- if something goes wrong when indexing the attachments of the content
-
indexContentAttachment
Index a content attachment -
indexContentAttachment
public void indexContentAttachment(Resource resource, Content content, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Index a content attachment -
_indexResourceDocument
protected void _indexResourceDocument(Resource resource, org.apache.solr.common.SolrInputDocument document, org.apache.solr.client.solrj.SolrClient solrClient) throws org.apache.solr.client.solrj.SolrServerException, IOException Index a populated solr input document of type Resource.- Parameters:
resource
- the resource from which the input document is createddocument
- the input documentsolrClient
- The solr client to use- Throws:
org.apache.solr.client.solrj.SolrServerException
- if there is an error on the serverIOException
- if there is a communication error with the server
-
deleteRepeaterDocs
protected void deleteRepeaterDocs(String contentId, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Delete repeater documents of a specified content.- Parameters:
workspaceName
- The workspace namecontentId
- the content ID.solrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
indexAllResources
public Map<String,Object> indexAllResources(String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) throws Exception Index all the resources in a given workspace.- Parameters:
workspaceName
- The workspace where to indexsolrClient
- The solr client to useprogressionTracker
- The progression of the indexation- Returns:
- The indexation result as a Map.
- Throws:
Exception
- if an error occurs while indexing.
-
indexResources
public org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult indexResources(Iterable<AmetysObject> resources, String documentType, String workspaceName) throws Exception Send a collection of contents for indexation in the solr server.- Parameters:
resources
- the collection of contents to index.documentType
- The document type of the resourceworkspaceName
- The workspace where to index- Returns:
- the indexation result.
- Throws:
Exception
- if an error occurs while indexing.
-
indexResources
public org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult indexResources(Iterable<? extends AmetysObject> resources, String documentType, TraversableAmetysObject resourceRoot, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Send a collection of contents for indexation in the solr server.- Parameters:
resources
- the collection of contents to index.documentType
- The document type of the resourceresourceRoot
- The resource root, can be null. In that case, it will be computed for each resource.workspaceName
- The workspace where to indexsolrClient
- The solr client to use- Returns:
- the indexation result.
- Throws:
Exception
- if an error occurs while indexing.
-
indexResources
public org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult indexResources(Iterable<? extends AmetysObject> resources, String documentType, TraversableAmetysObject resourceRoot, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) throws Exception Send a collection of contents for indexation in the solr server.- Parameters:
resources
- the collection of contents to index.documentType
- The document type of the resourceresourceRoot
- The resource root, can be null. In that case, it will be computed for each resource.workspaceName
- The workspace where to indexsolrClient
- The solr client to useprogressionTracker
- The progression of the indexation- Returns:
- the indexation result.
- Throws:
Exception
- if an error occurs while indexing.
-
doIndexResources
protected org.ametys.cms.content.indexing.solr.SolrIndexer.IndexationResult doIndexResources(Iterable<? extends AmetysObject> resources, String documentType, TraversableAmetysObject resourceRoot, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient, SimpleProgressionTracker progressionTracker) throws Exception Send some resources for indexation in the solr server.- Parameters:
resources
- the resources to index.documentType
- The document type of the resourceresourceRoot
- The resource root, can be null. In that case, it will be computed for each resource.workspaceName
- The workspace where to indexsolrClient
- The solr client to useprogressionTracker
- The progression of the indexation- Returns:
- the indexation result.
- Throws:
Exception
- if an error occurs committing the results.
-
indexResource
public void indexResource(Resource resource, String documentType, String workspaceName) throws Exception Add or update a resource into Solr index- Parameters:
resource
- The resource to indexdocumentType
- The document type of the resourceworkspaceName
- The workspace where to index- Throws:
Exception
- if an error occurs while indexing.
-
unindexResourcesByPath
Delete all resource documents at a given path for all workspaces and commit- Parameters:
rootId
- The resource root ID, must not be null.path
- The resource path relative to the given root, must start with a slash.- Throws:
Exception
- If an error occurs while unindexing.
-
unindexResourcesByPath
public void unindexResourcesByPath(String rootId, String path, String workspaceName) throws Exception Delete all resource documents at a given path.- Parameters:
rootId
- The resource root ID, must not be null.path
- The resource path relative to the given root, must start with a slash.workspaceName
- The workspace where to work in- Throws:
Exception
- If an error occurs while unindexing.
-
unindexResource
Remove a resource from Solr index for all workspaces and commit- Parameters:
resourceId
- The id of resource to unindex- Throws:
Exception
- if an error occurs while indexing.
-
unindexResource
Remove a resource from the Solr index.- Parameters:
resourceId
- The id of resource to unindexworkspaceName
- The workspace where to work in- Throws:
Exception
- if an error occurs while unindexing.
-
doIndexExplorerItem
protected void doIndexExplorerItem(AmetysObject node, String documentType, TraversableAmetysObject resourceRoot, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Add or update a resource into Solr index- Parameters:
node
- The resource to indexdocumentType
- The document type of the resourceresourceRoot
- The resource root, can be null. In that case, it will be computed for each resource.solrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
doIndexResource
protected void doIndexResource(Resource resource, String documentType, TraversableAmetysObject resourceRoot, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Add or update a resource into Solr index- Parameters:
resource
- The resource to indexdocumentType
- The document type of the resourceresourceRoot
- The resource root, can be null. In that case, it will be computed for each resource.solrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
commit
Process a Solr commit operation in all workspaces.
Use this only after a long operation with updates sent viaNoAutoCommitUpdateClient
- Throws:
org.apache.solr.client.solrj.SolrServerException
- if there is an error on the serverIOException
- if there is a communication error with the server
-
commit
public void commit(String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws org.apache.solr.client.solrj.SolrServerException, IOException Process a Solr commit operation in given workspace.- Parameters:
workspaceName
- The workspace's namesolrClient
- The solr client to use- Throws:
org.apache.solr.client.solrj.SolrServerException
- if there is an error on the serverIOException
- if there is a communication error with the server
-
optimize
public void optimize(String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws org.apache.solr.client.solrj.SolrServerException, IOException Launch a solr index optimization.- Parameters:
workspaceName
- The workspace's namesolrClient
- The solr client to use- Throws:
org.apache.solr.client.solrj.SolrServerException
- if there is an error on the serverIOException
- if there is a communication error with the server
-
unindexAllDocuments
public void unindexAllDocuments(String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Delete all documents from the solr index.- Parameters:
workspaceName
- The workspace namesolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while unindexing.
-
doUnindexDocument
protected void doUnindexDocument(String id, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Delete a document from the Solr server.- Parameters:
id
- The id of the document to delete from SolrworkspaceName
- The workspace namesolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
doUnindexContentAttachments
protected void doUnindexContentAttachments(String contentId, String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient) throws Exception Delete content attachments documents of a given content from the Solr server.- Parameters:
contentId
- The id of the contentworkspaceName
- The workspace namesolrClient
- The solr client to use- Throws:
Exception
- if an error occurs while indexing.
-
DateUtils.zonedDateTimeToString(java.time.ZonedDateTime, java.time.ZoneId)
using UTC zone id instead