Building Maven Central Search: Leveraging Solr and AJAX

Maven Central Building Blocks

June 27, 2011
By Joel Orlina

3 minute read time

In my last post, I explained the REST-style API that underlies Maven Central's browser-based search UI. That API essentially comes "for free" with the main components on which Maven Central Search is built:

In this post, I will highlight those components and describe how they were used to implement Maven Central Search.

When we started the project, we looked at a few options for implementing search, including Solr and the existing Nexus search capability built directly on top of Apache Lucene. The Nexus approach initially seemed compelling, as we clearly have significant experience with it. Nexus search even provides a REST API for full-text search that we could have leveraged. So, why did we end up choosing Solr when we could have simply re-used the search functionality in Nexus or even crafted a web UI backed by an instance of Nexus running on top of Central?

Two reasons:

Once we decided to use Solr, we quickly discovered that practically all the search functionality we needed came "out-of-the-box" with Solr's REST API. In fact, the entire second half of the Maven Central API Guide is simply a set of URLs proxied to our running Solr instance. We proxy the requests so that we can filter and transform inbound requests, to prevent a malformed or malicious request from taking down our server.

Next, we turned our attention to the browser-based user interface to call that API. Solr provides an administrative interface out of the box that includes search functionality. However, administrative interfaces tend to be utilitarian. We wanted our interface to be clean, but also to be a little more interactive, not just at launch, but as we added new features. So, we started researching AJAX- or JavaScript-based UIs that could sit on top of Solr, and found ajax-solr.

The ajax-solr website is a great resource for understanding the architecture of ajax-solr and provides an excellent tutorial for building your first Solr-powered AJAX-based website. Our developers took hold of that tutorial and quickly fashioned a prototype version of Central Search. During development, two major benefits of ajax-solr stood out:

In summary, we used several standard open source Java components to build the Maven Central search, and along the way our team added several new tools to our bag of tricks. We now have a strong foundation for continuing improvement of Maven Central. We hope you have found the new features useful, and we look forward to hearing your feedback at Get Satisfaction.

Written by Joel Orlina
Joel is a Senior Java Developer at Sonatype. He is based in Texas.