Spring Data for Apache Solr

Spring Data for Apache Solr, part of the larger Spring Data family, provides easy configuration and access to Apache Solr Search Server from Spring applications. It offers both low-level and high-level abstractions for interacting with the store.

Derived queries and annotations for Solr specific functionallity allow easy integration into existing applications.

Quick Start
Fork me on GitHub


  • High level repository abstractions with multicore support
  • Annotations for Boost-, Facet- and Highlighting
  • Customizable type mappings and type conversions
  • Solr template supporting fluent query api
  • Exception translation to Spring’s portable Data Access exception hierarchy

Quick Start


The recommended way to get started using spring-data-solr in your project is with a dependency management system – the snippet below can be copied and pasted into your build. Need help? See our getting started guides on building with Maven and Gradle.


@EnableSolrRepositories(basePackages={"com.acme.solr"}, multicoreSupport=true)
public class SolrContext {

  static final String SOLR_HOST = "solr.host";

  @Resource private Environment environment;

  public SolrServer solrServer() {
    String solrHost = environment.getRequiredProperty(SOLR_HOST);
    return new HttpSolrServer(solrHost);

Repository Usage

public interface SolrProductRepository extends SolrCrudRepository<Product, String> {

  Page<Product> findByPopularity(Integer popularity, Pageable page);

  Page<Product> findByNameOrDescription(@Boost(2) String name, String description, Pageable page);

  HighlightPage<Product> findByNameIn(Collection<String> name, Page page);

  @Query(value = "name:?0")
  @Facet(fields = { "cat" }, limit=20)
  FacetPage<Product> findByNameAndFacetOnCategory(String name, Pageable page);

Sample Projects

  • Solr Showcase - A Spring MVC application rebuilding parts of the original Solr example.