Wednesday, 1 July 2015

Configuring AEM 6.0 with remote SOLR server

Apache Jackrabbit Oak is the next generation repository implementation which powers in AEM 6.0. Oak does not index content by default to offer improved performance. Every JCR query will traverse whole repository, impacting the performance of the repository. Custom indexes need to be created to reduce node traversal with for every query in the repository.

The SOLR index


There are multiple options to index data in AEM, in this post we will be covering "The SOLR index".The Solr index in oak can be used for any type of JCR query. The integration in AEM 6.0 happens at repository level so Solr is one of the possible indexes that can be used in oak. 

Here are the steps for configuring AEM 6.0 with remote SOLR server : 

  1. First extract the Solr zip prior to version 5.0 (I used solr 4.9.1) in folder named Solr .
  1. This solr folder should be parallel to crxfolder folder AEM installation directory, i.e inside Author directory.

  1. Copy the example folder and paste in the same directory (Solr), rename the folder as node1 (any name).

  1. Repeat step 3, just rename the folder as node2.

  1. Create a folder in node1 and node2 with name cfg. Inside this folder paste solr.xml, zoo.cfg and oak core config folder. (I used default core collection1 in my case)

  1. Now start the first solr shard with zookeeper configured. Run the following command from node1 directory :

java -Xmx256m -Dbootstrap_confdir=./cfg/oak/conf
-Dcollection.configName=myconf -DzkRun -DnumShards=2 -jar start.jar

  1. Now start the second shard by running the following command from node2 directory :
java -Xmx256m -Djetty.port=7574 -DzkHost=temphost.ig.com:9983 -jar  start.jar
Catch here is Solrcloudserver does not use the URL for initialization, rather it uses the connection string. Connnection string is same we pass with the zkHost parameter. In my case it was not working if I passed value as localhost:9983. I had to create a custom host name and the pass the same connection string while configuring with AEM.

  1. Once second shard is up and running, check if it both the shards are working or not by accessing the url :

http://localhost:8983/solr/#/~cloud

  1. Now open the Configuration Manager console (localhost:3502/system/console/configMgr), and set the value of Oak Solr server provider as Remote Solr from drop down.

  1. Now edit Oak Solr remote server configuration and set the values as :

Solr HTTP URL : http://localhost:8983/solr/
ZooKeeper host : http://temphost.ig.com:9983
Solr collection : collection1
No. of collection shards : 2
Replication factor : 1
Solr configuration directory : /home/codebrains/CQ_Instance/Author/solr/node1/cfg/oak

solrremoteconfig.png

  1. Now open the CRXDE Lite and create a node under oak:index with following properties :
Name : solrindex (String)
jcr:primaryType : oak:QueryIndexDefinition
reindex : true (Boolean)
async : async
type : solr