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
Fields Modifier and Type Field Description protected String
_ametysInternalUrl
The Ametys internal URL used by Solr to query Ametysprotected Context
_context
The avalon contextprotected ReadAccessHelper
_readAccessHelper
The helper for read accessprotected JackrabbitRepository
_repository
The JCR repositoryprotected AmetysObjectResolver
_resolver
The ametys object resolver.protected SchemaDefinitionProviderExtensionPoint
_schemaDefProviderEP
The schema definition provider extension point.protected SchemaHelper
_schemaHelper
The schema helper.protected SolrClientProvider
_solrClientProvider
The Solr client providerprotected SolrContentIndexer
_solrContentIndexer
Solr Ametys contents indexerprotected String
_solrCorePrefix
The solr core prefix.protected SolrResourceIndexer
_solrResourceIndexer
Solr resource indexer.protected SolrWorkflowIndexer
_solrWorkflowIndexer
Solr workflow indexer.protected WorkspaceSelector
_workspaceSelector
The workspace selector.static String
ROLE
The component role.
-
Constructor Summary
Constructors Constructor Description SolrIndexer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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
commit(String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient)
Process a Solr commit operation in given workspace.void
contextualize(Context context)
void
createCore(String name)
Create a Solr core.static SimpleDateFormat
dateFormat()
Returns the formatter for indexing dates.protected boolean
definitionExists(SchemaDefinition definition, SchemaFields schemaFields)
Test if the given schema definition exists in the givenSchemaFields
reference.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)
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)
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.Set<String>
getCoreNames()
Get the names of the Solr cores.protected Set<String>
getRealCoreNames()
Get the names of the Solr cores.protected org.apache.solr.client.solrj.request.schema.SchemaRequest.Update
getSchemaUpdate(SchemaDefinition definition)
Get the schemaSchemaRequest.Update
directive from the given schema definition.void
indexAclInitValues(AmetysObject ametysObject, org.apache.solr.common.SolrInputDocument document)
Indexes read-ACl initial values for objectMap<String,Object>
indexAllContents(String workspaceName, boolean indexAttachments, org.apache.solr.client.solrj.SolrClient solrClient)
Index all the contents in a given workspace.Map<String,Object>
indexAllResources(String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient)
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.void
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<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
initialize()
void
optimize(String workspaceName, org.apache.solr.client.solrj.SolrClient solrClient)
Launch a solr index optimization.void
reloadAclCache()
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
reloadCores()
Reload the solr cores.protected void
reorderUpdates(List<org.apache.solr.client.solrj.request.schema.SchemaRequest.Update> updates)
Reorder the list ofSchemaRequest.Update
directives.void
sendSchema()
Send the schema.void
service(ServiceManager serviceManager)
static String
truncateUtf8StringValue(String value, org.slf4j.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
updateAmetysUrlCoreProperty()
Updates the ametys.url property of the Solr cores.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 Detail
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver.
-
_schemaDefProviderEP
protected SchemaDefinitionProviderExtensionPoint _schemaDefProviderEP
The schema definition provider extension point.
-
_schemaHelper
protected SchemaHelper _schemaHelper
The schema helper.
-
_solrContentIndexer
protected SolrContentIndexer _solrContentIndexer
Solr Ametys contents indexer
-
_solrWorkflowIndexer
protected SolrWorkflowIndexer _solrWorkflowIndexer
Solr workflow indexer.
-
_solrResourceIndexer
protected SolrResourceIndexer _solrResourceIndexer
Solr resource indexer.
-
_solrClientProvider
protected SolrClientProvider _solrClientProvider
The Solr client provider
-
_solrCorePrefix
protected String _solrCorePrefix
The solr core prefix.
-
_ametysInternalUrl
protected String _ametysInternalUrl
The Ametys internal URL used by Solr to query Ametys
-
_workspaceSelector
protected WorkspaceSelector _workspaceSelector
The workspace selector.
-
_repository
protected JackrabbitRepository _repository
The JCR repository
-
_readAccessHelper
protected ReadAccessHelper _readAccessHelper
The helper for read access
-
-
Constructor Detail
-
SolrIndexer
public SolrIndexer()
-
-
Method Detail
-
dateFormat
public static SimpleDateFormat dateFormat()
Returns 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, org.slf4j.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
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
_getAutoCommitSolrClient
protected org.apache.solr.client.solrj.SolrClient _getAutoCommitSolrClient(String workspaceName)
Gets the 'autocommit' Solr client- Parameters:
workspaceName
- The name of the workspace- Returns:
- the Solr client
-
_getNoAutoCommitSolrClient
protected org.apache.solr.client.solrj.SolrClient _getNoAutoCommitSolrClient(String workspaceName)
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.SolrServerException
Get 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.SolrServerException
Get 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
public void 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
public void sendSchema() throws IOException, org.apache.solr.client.solrj.SolrServerException
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).
-
reorderUpdates
protected void reorderUpdates(List<org.apache.solr.client.solrj.request.schema.SchemaRequest.Update> updates)
Reorder the list ofSchemaRequest.Update
directives.- Parameters:
updates
- The list ofSchemaRequest.Update
directives to reorder.
-
definitionExists
protected boolean definitionExists(SchemaDefinition definition, SchemaFields schemaFields)
Test if the given schema definition exists in the givenSchemaFields
reference.- Parameters:
definition
- The schema definition to test.schemaFields
- The current schema fields.- Returns:
- true if the SchemaFields contain the schema definition.
-
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.
-
getSchemaUpdate
protected org.apache.solr.client.solrj.request.schema.SchemaRequest.Update getSchemaUpdate(SchemaDefinition definition)
Get the schemaSchemaRequest.Update
directive from the given schema definition.- Parameters:
definition
- The schema definition to add.- Returns:
- The add
SchemaRequest.Update
directive.
-
reloadCores
protected void reloadCores() throws IOException, org.apache.solr.client.solrj.SolrServerException
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, RepositoryException
Reloads 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.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, 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.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, 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.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.
-
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
public void indexSubcontents(String collectionId, boolean indexAttachments) throws Exception
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
public void indexContent(String contentId, boolean indexAttachments) throws Exception
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, 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.
-
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) 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 use- 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.
-
unindexContent
public void unindexContent(String contentId, boolean unindexAttachments) throws Exception
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
public void unindexContents(Collection<String> contentIds) throws Exception
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
public void unindexContents(Collection<String> contentIds, String workspaceName) throws Exception
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
public void indexContentAttachment(Resource resource, Content content) throws Exception
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) throws Exception
Index all the resources in a given workspace.- Parameters:
workspaceName
- The workspace where to indexsolrClient
- The solr client to use- 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.
-
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) 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 use- 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
public void unindexResourcesByPath(String rootId, String path) throws Exception
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
public void unindexResource(String resourceId) throws Exception
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
public void unindexResource(String resourceId, String workspaceName) throws Exception
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
public void commit() throws org.apache.solr.client.solrj.SolrServerException, IOException
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.
-
-