Support of Apache Solr for Spring Data

CAST supports Apache Solr for Spring Data via its com.castsoftware.nosqljava extension, since release 1.9. Details about the support provided for Java with Spring Data source code are discussed below.

Supported Libraries

Library Version Supported
Spring Data Apache Solr Up to: 4.3.x ✔️

Supported Operations

Operation Scenario Methods Supported
Insert Repository APIs
Solr Template APIs
Select Repository APIs
Solr Template APIs
Delete Repository APIs
Solr Template APIs


Icon Description
Java ApacheSolr Client
Java ApacheSolr Index
Java Unknown ApacheSolr Index
Link type Source and destination of link Methods supported
parentLink Between Apache Solr Index Object (Collection → Client ) -
useSelectLink Between the caller Spring Data Java Method objects and Apache Solr Index findAll
useDeleteLink Between the caller Spring Data Java Method objects and Apache Solr Index deleteAll
useInsertLink Between the caller Spring Data Java Method objects and Apache Solr Index save

What results can you expect?

Some example scenarios are shown below:

ApacheSolr Client

public class Order {
    @Indexed(name = "oid", type = "long")
    private Long orderid;
    @Indexed(name = "oname", type = "string")
    private String orderName;
    @Indexed(name = "odesc", type = "string")
    private String orderDescription;
    @Indexed(name = "pname", type = "string")
    private String productName;

    @Indexed(name = "cname", type = "string")
    private String customerName;
    @Indexed(name = "cmobile", type = "string")
    private String customerMobile;

	public Long getOrderid() {
		return orderid;

	public void setOrderid(Long orderid) {
		this.orderid = orderid;

	public String getOrderName() {
		return orderName;

	public void setOrderName(String orderName) {
		this.orderName = orderName;

	public String getProductName() {
		return productName;

	public void setProductName(String productName) {
		this.productName = productName;

	public String getCustomerName() {
		return customerName;

	public void setCustomerName(String customerName) {
		this.customerName = customerName;

	public String getCustomerMobile() {
		return customerMobile;

	public void setCustomerMobile(String customerMobile) {
		this.customerMobile = customerMobile;

	public String getOrderDescription() {
		return orderDescription;

	public void setOrderDescription(String orderDescription) {
		this.orderDescription = orderDescription;

Insert Operation

Insert Operation

	public String updateOrder(@RequestBody Order order){
		String description = "Order Updated";;
		return description;

Select Operation

Select Operation

	public Iterable<Order> getOrder() {
		return solrOrderRepository.findAll();

    public ScoredPage<Book> searchDocuments(String searchTerm) {
        Query query = new SimpleQuery(searchTerm);
        return solrTemplate.query("Book", query, Book.class);

    @Query("odesc:*?0* OR oname:*?0* OR pname:*?0*")
    Page<Order> findByCustomerQuery(String searchTerm, Pageable pageable);

Delete Operation

Delete Operation

	public String deleteOrder(@PathVariable Long orderid){
		String description = "Order Deleted";
		return description;

Known Limitations

  • If the Index/core name is not resolved in the CRUD API, then a link is created with an unknown index object.