Expand my Community achievements bar.

SOLVED

Any experience integration AEM 5.6.1 with SOLR

Avatar

Level 2

In our project we need to have AEM use a standalone SOLR search server and index all the AEM content in this server. Has anyone implemented this? How do we configure AEM to not use built in Lucene but search and fetch results from an external search engine?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

In AEM 5.6.1 there is not built-in solr available, but you can easily attach a solr instance to AEM and feed all content updates to it.  See the references Alva gave in the earlier response.

But: You cannot replace the builtin Lucene by Solr. The JCR query language always uses the builtin Lucene. So you can build your site search on Solr (oh, don't forget that solr knows nothing about your ACLs ...), but nothing more.

kind regards,

Jörg

View solution in original post

8 Replies

Avatar

Correct answer by
Employee Advisor

In AEM 5.6.1 there is not built-in solr available, but you can easily attach a solr instance to AEM and feed all content updates to it.  See the references Alva gave in the earlier response.

But: You cannot replace the builtin Lucene by Solr. The JCR query language always uses the builtin Lucene. So you can build your site search on Solr (oh, don't forget that solr knows nothing about your ACLs ...), but nothing more.

kind regards,

Jörg

Avatar

Level 2

When you say "But: You cannot replace the builtin Lucene by Solr. The JCR query language always uses the builtin Lucene." --> I don't want the search to happen in CQ I need it to happen on the external SOLR server...how does that happen? How does one bypass Lucene?

Avatar

Level 6

high level steps - 

1. If you want to create Solr index to be created on CQ startup then on activate method or you can call from a servlet to do the below -

 1a. check for solr instance is up 1b. Get the resourceResolver for jcr content path(/content/geometrixx) that you want to index. 1c. Using resourceResolver get the /foundation/components/text, foundation/components/parsys or any custom text component

1d. fetch the jcr:title, jcr:description etc from previous steps and put it in a map. 1e. Pass this map to Solr using SolrJ apis which will create index in Solr

2. On page activation 

2a. Create Eventlistner to listen page activation event  2b. Follow the steps from 1a

3. Fetch the index

3a. create a component and from component's jsp file call servlet through AJAX call and pass the search parameter

3b. Once u get the searc parameter then write few lines of code to call Solr apis - SolrQuery query = new SolrQuery(q);
........
QueryResponse result = new HttpSolrServer(solrServerUrl).query(query); 

Hope it helps!

Avatar

Employee Advisor

Hi,

to make it clear: When you use "session.getWorkspace().getQueryManager().createQuery(...).execute()", you will use the builtin Lucene index. When you use the QueryBuilder, you will use the builtin Lucene index. You cannot change that.

For all other cases you can use Solr (probably using the SolrJ API), but then you need to feed the content you want to be searchable to Solr first.

Jörg

Avatar

Level 2

Thank you for the details very helpful. What I am not clear on is when someone on publish searches (end user facing public site) for something how do I make it fetch data from SOLR? I understand that I cannot bypass LUCENE so every time I search it will hit Lucene?

The requirement is: I have to ensure that the data is being searched in SOLR engine as I need to be search and mashup data that is being pushed to SOLR from another system (outside of CQ) as well. So basically, I have to search through CQ data + data from another system and show it in Search Results page hosted by CQ

Avatar

Level 6

i have updated my previous answer #3