Friday 27 July 2018

Understanding Indexing in AEM

Older version of AEM/ CQ, Jackrabbit index the content by default. But Oak doesn't index content by default. We need to do it like how we do indexing for a DataBase.

Why do we need to index?
When a JCR query gets executed, usually it searches the index first. If there is no index, the query executes for the entire content. This is time consuming and an overhead for the AEM. But keep in mind, if the frequency of queries executed are less, we can ignore the indexing.

Let us understand the Oak and AEM indexing in detail here.

In fact, there are three main types of indexes available in Oak
  • Property
  • Lucene
  • Solr
And below are the supported query languages from Oak
  • XPath (recommended)
  • SQL-2
  • SQL (deprecated)
  • JQOM
AEM allows writing queries in one of three ways:
  • QueryBuilder APIs (recommended)
  • Using XPath (recommended)
  • Using SQL2
Note: all queries are converted to SQL2 before being run,

Indexing modes
Different versions of the node data is compared to find indexes. The indexing mode defines how comparison is performed, and when the index content gets updated. Below given the indexing mode and details.

Sync Vs  Async Vs Nrt
  • Async - When we index in async mode, results returned by index may not always reflect the exact up to date state of the repository.
  • Sync - Sync Index ensures that index is updated as part of each commit.
  • NRT - This method indicates that index is a near real time index.
The flow of index is given in below image.
*Click on image to view it big and more clear.

[Indexing in AEM 6.4]



Below given various indexes in detail.

Property Index - Not a full-text indexing method. Index definition is stored in the repository itself.

Configuration
type: property;
propertyNames: jcr:uuid (of type Name)

Ordered Index - [deprecated] - This is an extension of the Property index. It keeps the order of the indexed property persistent in the repository.

Configuration
type: ordered;
propertyNames: jcr:lastModified

Lucene Full Text Index - This is a full text index method, which is asynchronous too.

Configuration
type: lucene ;
async: async

Lucene Property Index - This is not a full-text indexing.

Configuration
 type: lucene ;
 async: async ;
 fulltextEnabled: false;
 includePropertyNames: ["alias"]

The Solr Index - This is a full-text search but it can also be used to index search by path, property restrictions and primary type restrictions, which means the Solr index in Oak can be used for any type of JCR query.

Configuration
type:solr;
async:async;
reindex:true

Traversal Index - When no indexing is done; All content nodes are traversed to find matches to the query, slower and overhead to AEM.

A tabular version is given below



[AEM Oak Indexing]


Video description of the blog given below.



 Read about AEM 6.4 Oak Queries and Indexing

Best Practices for Queries and Indexing

Monday 23 July 2018

Single Page Applications and AEM

What is Single Page Applications - SPA?

Single Page applications are pages which dynamically update its content using AJAX calls to create a fluid & responsive experience.

In traditional applications, each request reloads/renders the HTML; but in SPA all interactions happens through AJAX calls. The return data is in JSON format. Previous versions of AEM had a miss on the SPA but with upcoming releases AEM SPA Editor provides a wonderful solution for supporting SPAs within AEM.

Single Page Applications - Features


  • This avoids page reloading.
  • Reusable Content.
  • Majority of the work happens in client side.
  • Good separation between content and UI
  • Provides interactive experience
  • RESTFul JSON


SPA(Single Page Applications) Basics

Below image gives an overview on the Single Page Applications in general.
As mentioned, only the first request is responded with a complete HTML. Further requests are made in AJAX way to the server and response in provided in JSON format.


SPA with AEM.
Latest AEM releases are enabling users to develop Single Page Applications using AEM. AEM SPA Editor allows user to author a page with Content Fragments in addition to other normal components like title, footer, images etc and AEM Sling models generate the Page equivalent JSON. This RESTFul JSON can be made available for other SPA frameworks like Angular React etc.


 In upcoming posts, I will explain, how to create SPA in AEM.


Video version of the post is available below.

 

AEM 6.4 related posts:
Create Content Fragments : Step By Step Tutorial
Content Fragment out put as JSON