Sample Application for the AEM-Solr Integration
After two quite theoretic posts about the basics of Solr in AEM and the schema configuration it's time for a practical one. If you have a local AEM instance running, you can use the application I pushed into the solr-aem Github repository1 to get a running website with Solr integration. The README.md2 gives a detailed view on the application therefor I constrain the blog post to the basics. The application includes a simple Search page where Paging8, Highlighting9 and Spell checking10 are used.
Setup a Solr schema.xml for AEM
Now that we have successfully convinced AEM to use Solr as Indexer, the next step is to create a Schema which is used by Solr for Index/Query Processing. Why do we need a schema? Solr does not know anything about your data structure but you want it to perform complex operation like fulltext searches, faceting etc. To allow Solr to create a fast index, you need to define which fields you want to index and which operations should be performed upon index or query1.
Create an AEM index utilizing Solr
Last month I discussed the options to use Elasticsearch as search engine for AEM content. The presented approach required a custom implementation of a replication agent available on Github1. As an alternative I'll demonstrate how the build in functionality of Jackrabbit Oak2 to index into Solr3 can be used. Just like Elasticsearch4 Solr is a search platform based on Lucene5. By default Jackrabbit uses the embedded Lucene index in AEM to create an index both for internal queries and custom, application-specific queries (using XPath and SQL-2).