Posts

Showing posts from May, 2020

Lucene Index in AEM - Part 1

Image
Lucene index supports both property constraints and full text constraints. Based on the index definition, it can be used to evaluate property constraints, full-text constraints, path restrictions and sorting.  Lucene Index Definition/Structure - High level: Mandatory Properties Name Type Value type String lucene async String[] Possible values - async, nrt, fultext-async Optional/Supporting Properties compatVersion Long 2 Oak uses Lucene index implementation that does not support  property constraints, index time aggregation by default. In order to use these features, set this property with value 2 blobSize Long 32768 (32kb - Default Value) Size of each index file in repository. (for splitting while storing in NodeStore) maxFieldLength  Long 10000 (Default value) Numbers of terms indexed per field name String name of the index This will be used while logging indexPath String Path of the index defintion If the index definition named customluceneIndex is defin

Property Index in AEM - Continued

Image
This post illustrate the usage of supporting properties that are part of Oak Property Index with sample use case.  Use case: DAM assets have a property called "cq:parentPath" ( jcr:content node of type - dam:AssetContent has this property which has the value to be its parent folder path) Example :  /content/dam/we-retail/en/features/cart.png/jcr:content We will write a query to get all assets from we-retail/en locale which has cq:parentPath property  path=/content/dam/we-retail/en type=dam:AssetContent 1_property=cq:parentPath 1_property.operation=exists p.limit=-1 Create Property Index for "cq:parentPath" with mandatory properties alone.  With this set up, this index will be picked for all queries involving this property constraint + any " path " predicate. Now to make this index to be used/picked for only certain paths we can control using   includedPaths and/or excludedPaths includedPaths: Add below property in newly created index node - /oak:inde

Property Index in AEM - Index properties and steps to create custom index

Image
Property Index is for queries involving property constraints - equality, exist/not null check on property. Oak property Index:  Node of type " oak:QueryIndexDefinition " with  Mandatory Properties Name Type Value type String property propertyNames Name[] list of properties for which the index needs to be created. Example: jcr:title, cq:lastModified, hideInNav  property for a page content cq:ParentPath property for an AEM Asset Optional/Supporting Properties declaringNodeTypes Name[] list of node types for which the index is applicable for Example: cq:PageContent rep:Authorizable unique Boolean true  Applicable for queries with unique constraint This property should be used along with declaringNodeTypes Example:   /oak:index/authorizableId includedPaths String[] paths that are included in this index. If not set, it is "/" For queries with path restrictions that is not excluded and part of included paths Example: Scenario 1: If two proper

Indexing in AEM - Indexing modes and Index types

Image
In order for queries to perform well, Oak supports indexing concept which will index content stored in the repository based on the index definition/type/indexing mode. Indexing works by comparison of the node state (Difference between base state and modified state ) where NodeState( org.apache.jackrabbit.oak.spi.state.NodeState ) respresents a specific immutable state of the node.  Below mentioned types of indexing modes are defined based on how this comparison is made + when the index content gets updated.  Indexing modes: Sychronous Indexing This mode updates index content as part of the commit to the actual content. In other words, content update and the respective update in index will happen together (as with the name synchronous) Supported Index Type: Property Index Asynchronous Indexing Index update is done via a scheduled jobs( AsyncIndexJobUpdate ) defined at specific interval. (5 seconds OOB) As indexing in this mode happens asynchronously irrespective of the