Monday, October 10, 2022

Control indexing in Alfresco with Alfresco Search Services

I came acorss a query from a friend to disable content indexing and allow only matadata indexing recently. The last time i tried this when i was using Alfresco 5.0 with Solr4. This time i tried with Alfresco Content Services 7.2.0.1 and Alfresco Search Services 2.0.3.5 and the good news is that, it still works. 

If your application does not require full-text content search capability, then disabling content indexing comes handy and increases the performance as well.

If you are curious to try out, then follow along.

Pre-requisites
  • You have an environment up and running with Alfresco Content Services 7.x and Alfresco Search Services 2.x (Solr6)
  • You have administrative privileges

Looking for Alfresco Content Services 7.x with Alfresco Search Services 2.x installation steps? , checkout these posts:




Content and metadata are indexed by default, it is out-of-the-box behavior. There are two ways you can control content/metadata indexing behavior in order to fulfil the search and indexing requirements. We will go over both options.

Control indexing behavior with help of content model aspect:


To control the indexing behavior, you can make use of a content model aspect named "cm:indexControl" which has two properties. These properties indicate whether content/metadata should be indexed.

The value of these properties are set to true by default.

<aspect name="cm:indexControl">
	<title>Index Control</title>
	<properties>
		<property name="cm:isIndexed">
			<title>Is indexed</title>
			<type>d:boolean</type>
			<default>true</default>
		</property>
		<property name="cm:isContentIndexed">
			<title>Is content indexed</title>
			<type>d:boolean</type>
			<default>true</default>
		</property>
	</properties>
</aspect>

You can apply cm:indexControl aspect on the nodes to control the indexing behavior by setting the appropriate properties. Note that, this approach works only for certain types like cm:folder, cm:content and sub-types. You need to keep in mind that, if you have a large number of nodes which needs to be excluded from content/metadata indexing then this option is not a right choice as you will have to apply the aspect by setting "cm:isContentIndexed" to "false" on all those nodes. 
In this situation second option (which we will see next) comes handy.

To learn more on content model, aspects and their application, refer:  Content Model Extension Point

If you wish to bulk apply the aspect with updated values, this post may be useful as a reference: Applying the aspects in bulk