Custom Oak Indexes : AEM Part-1 (Custom Index Creation)

With latest version of AEM,  Oak does not index content by default, Custom indexes need to be created as per the requirement. If there is no index for a specific query, possibly many nodes will be traversed. The query may still work but probably be very slow. So let's quickly  create a custom Index. We will explore below search features.

  1. Synonyms Words
  2. Stop Words
  3. Autosuggestion
  4. PorterStem & Lower Case

For Creating Lucene custom Index step please follow below steps

  • Open CRXDE and navigate to http://localhost:4502/crx/de/index.jsp
  • Navigate to /oak:index
  • Create node with jcr:primaryType = oak:QueryIndexDefinition


Index must have below properties while creating it

  • must be of type oak:QueryIndexDefinition
  • must have the type property set to lucene
  • must contain the async property set to the value async, this is what sends the index update process to a background thread
  • Click save all and save your changes.
Below are the non mandatory but useful properties that we can add for optimized indexing

  • compatVersion  Required integer property and should be set to 2
By default Oak uses older Lucene index implementation which does not supports property restrictions index time aggregation etc. To make use of this feature set it to 2. Please note for full text indexing with compatVersion 2, at query time, only the access right of the parent (aggregate) node is checked, and the access right of the child nodes is not checked. If this is a security concern, then compatVersion should not be set, so that query time aggregation is used,in which case the access right of the relevant child is also checked. A compatVersion 2 full text index is usually faster to run queries.

  •  evaluatePathRestrictionsOptional boolean property defaults to false

    If enabled the index can evaluate path restrictions

  • includedPathsOptional multi value property. Defaults to ‘/’

    List of paths which should be included in indexing.

  • excludedPathsOptional multi value property. Defaults to empty

    List of paths which should be excluded from indexing.

  • queryPathsOptional multi value property. Defaults to ‘/’

    List of paths for which the index can be used to perform queries. Refer to Path Includes/Excludes for        more details

  • indexPathOptional string property to specify index path

   Path of the index definition in the repository. For e.g. if the index definition is specified        at /oak:index/lucene then set this path in indexPath

For all available  properties please visit jackrabbit-oak documentation click

Hope this helps!!

Happy Coding 🙏

If you like my post and find it helpful, you can buy me a coffee.

Part -2 


Custom Oak Indexes : AEM Part-2 ( Synonyms Words )

Comments